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
Unable to build
(or preview
) a project that runs fine with dev
#1783
Comments
If you need the tone library clientside what about using a default import like recommended in the error message? You could also do |
Otherwise the library would need to provide an esm version afaik. |
Thanks, yeah the issue appears to be the esm imports that |
This type of question is best asked on StackOverflow or Discord |
I did ask on Discord, but I got no helpful responses. I figured if SvelteKit (or vite?) was incorrectly rewriting esm imports that would constitute a bug. Thanks anyway. |
Update -- ended up switching to something else instead of SvelteKit :( |
Those libraries should specify
Which gives the error message:
It actually does contain it as far as I can tell though perhaps there's something going on with it being in a The issue occurs when SvelteKit tries to import this file. The import is handled by Node, so it's either a bug in Node or in |
Thanks, yeah, I think it's something funky in the way |
I have the same issue with chart.js. @benmccann what about libraries that have a |
@peterszerzo : Just found out that you can import with ESM path and it works just fine: import Chart from 'chart.js/auto/auto.esm'; Hint: I found it on SvelteKit discord 😃 |
I filed an issue for Chart.js: chartjs/Chart.js#9436 You can also make it work by setting |
Appreciate your support @quangpdt and @benmccann! |
@benmccann, I updated to "vite": 3.0.0 and cart-js is not working anymore with import Chart from 'chart.js/auto/auto.esm'; |
@esyon can you file a new issue with a project to reproduce it? |
@benmccann, new issue: #5535 Thanks for your support! |
Describe the bug
Unable to
build
(orpreview
) a project that runs fine withdev
.My project (converted from a Svelte / Snowpack project) runs properly with
npm run dev
, but fails whennpm run build
ing using@sveltejs/adapter-static
or when usingnpm run preview
with no adapter installed.Minimal demo repo at https://github.com/simonwiles/kit-tonejs-piano.
Logs
To Reproduce
git clone https://github.com/simonwiles/kit-tonejs-piano
cd kit-tonejs-piano
npm install
npm run build
Expected behavior
I want to be able to build it :)
Information about your SvelteKit Installation:
Diagnostics
npx envinfo --system --npmPackages svelte,@sveltejs/kit,@sveltejs/adapter-node,@sveltejs/adapter-static,@sveltejs/adapter-begin,@sveltejs/adapter-netlify,@sveltejs/adapter-vercel vite --binaries --browsers
Severity
This is a blocker for the app, of course. The full-scale app works just fine without SvelteKit (see https://sul-cidr.github.io/pianolatron -- still under heavy development), but we need some static-site apparatus around it, and I'd like to use SvelteKit.
Additional context
I'm not 100% sure if this is a problem that needs to be fixed in SvelteKit or
@tonejs/piano
or, as I suspect, both. I've tried rewriting all the tone.js imports in a fork of@tonejs/piano
, but to no avail. Pointers for further debugging very welcome.The text was updated successfully, but these errors were encountered: