tsparticles / svelte

Svelte tsParticles official plugin
MIT License
43 stars 3 forks source link

Cannot use import statement outside a module #13

Closed Shrumpf closed 1 year ago

Shrumpf commented 1 year ago

After updating my project I get the exception Cannot use import statement outside a module. I couldn't find the exact problem, but this is a standard SvelteKit project on the latest versions and it doesn't work.

image

Reproduce: https://replit.com/@Shrumpf/Particles

It doesn't happen everytime, sometimes the error shows up after changing the page and after switching back it works.

Probably I just use it the wrong way, but maybe someone has an idea.

matteobruni commented 1 year ago

I added a SvelteKit demo app in this repository, the solution is described in the readme as well: https://github.com/tsparticles/svelte#sveltekit

I got the same error and I solved it changing the vite.config.ts file like this:

https://github.com/tsparticles/svelte/blob/836addd212b91aff79c0c52bd147cb43a5667368/apps/svelte-kit/vite.config.ts#L1-L9