-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sveltekit crashing on certain external libraries #2670
Comments
I guess this issue is related to this? #1895 |
It's related to this: vitejs/vite#2579 We would need to wait for that to be resolved, but otherwise the easier path is to have colortranslator export ESM code as well. Currently, it's CJS only. |
I have a bunch of other modules that have the same problem though- don't really feel like forking all of their repos, and then changing their bundling settings manually. Is there a workaround? I don't really need the SSR, would turning that off solve it? EDIT: found it in the docs: https://kit.svelte.dev/docs#ssr-and-javascript-ssr. |
You can submit a PR to the repos instead of forking, it's great to move the ecosystem towards ESM too as that's the goal of VIte. Yeah you can try turning SSR to false as mentioned in your edit, but keep in mind that it's not 100% true SPA yet (#1650). Or you can also use Vite directly if needed. |
What do you mean with using 'Vite directly'? Is there a template/example of how that would work? |
You can create a Vite app with |
I filed a feature request for the library to support ESM: elchininet/ColorTranslator#56 That library is written in TypeScript and compiled to CJS. It'd be easy to compile an ESM version alongside it. The whole ecosystem is moving to ESM, so that should really be done long-term even after Vite adds better support for CJS |
I'm going to go ahead and close this since there's nothing else we can do in SvelteKit. The changes that need to be made are in ColorTranslator and Vite and tracked by issues there |
@luucvanderzee ColorTranslator 1.8.0 now distributes an ESM version: https://github.com/elchininet/ColorTranslator/blob/87d36e06295d5fb63e28cbaae9a16ad049e839ca/package.json#L7 Hopefully this fixes your issue! |
Describe the bug
When I try to use certain libraries, Sveltekit crashes. In this example I am using colortranslator, but it also happens with other packages.
Reproduction
On the command line:
Then in
src/routes/index.svelte
, add the following line:This produces the following error:
Line must be greater than or equal to 1, got -1
(see log below for more details)Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: