-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Cannot use Wasm: Failed to parse URL from .../lib_bg.wasm?init #6733
Comments
Can you provide a GitHub repository with the reproduction? We get too many bugs filed to create the reproduction for each one This is either a bug with Vite or Undici and not with SvelteKit itself. It'd be nice to figure out which one so you can file the bug in the right place. https://github.com/sveltejs/kit#bug-reporting |
Thanks for the quick reply, As mentioned in the issue description, I've pushed the code to this repo: https://github.com/nmattia/svelte-rust-wasm/tree/main/sveltekit-app
The repo contains two very similar apps that use the same Wasm module; one is the svelte + vitejs default template, the other one the sveltekit default template. I'm curious why the svelte + vitejs one works out of the box. EDIT: I've just committed the Wasm code as well. You just just need to run |
It's most likely either because the svelte + vitejs one doesn't use SSR (see https://github.com/sveltejs/kit#bug-reporting for details) or because it doesn't use Undici. Either way, you're probably going to need to file this issue elsewhere to see it addressed |
Seems related: vitejs/vite#8882 |
We use wasm-pack generated modules with SSR using this vite plugin: https://github.com/omnysecurity/vite-plugin-wasm-esm. Works well for us, but you have to use |
Describe the bug
Importing a Wasm module fails, whereas a simple (non-sveltekit) svelte app can load and use the Wasm module just fine.
I'm generating the Wasm module (and project that includes a few js wrappers) using wasm-pack.
Additionally to the repro steps below, I've pushed the code here. This contains three projects:
lib
, a rust library that gets compiled to wasm (to avoid building it, usepkg.zip
attached in "Reproduction" belowsvelte-app
, a (default template) svelte app (without sveltekit) that can make use of the Wasm filesveltekit-app
, a (default template) sveltekit app that fails onnpm run dev
but succeeds onnpm run build
, although the resulting build is broken.Reproduction
Initialize a sveltekit project:
Add necessary dependencies:
Update
vite.config.ts
:Call e.g. the
greet
function from the Wasm module from a page:Run
npm run dev
:I've attached the
pkg/
which contains the Wasm module (can be a bit cumbersome to generate otherwise).pkg.zip
Logs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: