Rich-Harris/svelte-cubed

500 error after build

henken opened this issue · 2 comments

I have created a very basic demo of a rotating plane locally using Sveltekit, three and svelte-cubed. It works fine locally.

After build, I get the following 500 error:
Must use import to load ES Module: /var/task/node_modules/three/examples/jsm/controls/OrbitControls.js

I narrowed my script down to only the import calls:

import * as THREE from 'three'; import * as SC from 'svelte-cubed';

This still throws the 500 error.

I then narrowed it down to just
import * as THREE from 'three';
and no errors are thrown.

FWIW, I'm using Netlify. I have deployed many Sveltekit sites up to this point without issue.

I had the same issue with vanilla three.js in my sveltekit app deployed on netlify. This is how my svelte.config.js looks like which fixed it for me.

import adapter from '@sveltejs/adapter-netlify';

export default {
	kit: {
		vite: {
			ssr: {
				noExternal: ["three"]
			}
		},
		adapter: adapter({
			// if true, will split your app into multiple functions
			// instead of creating a single one for the entire app
			split: false
		})

	}
};

The solution posted above by @stefanreifenberg solved the issue!