You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is pretty much identical to this bug: #2480, it appears imports.meta.url is still blank in the "next" target of @sveltejs/kit. The primary difference is that I compile Rust into WASM. The JS wrapper that wraps it includes this function, and import.meta.url appears to be blank, causing an error.
I stumbled on this trying to use the vite-plugin-wasm-pack, which builds successfully, but fails whenever you load the page with the error log described below.
As can be seen in the last error log line, the base is never added to the wasm path file. Providing the full path of the wasm to the init() function fixes the issue.
Reproduction
Here is a the sveltekit demo repo. Note that you have have to have the rust toolchain and wasm-pack installed, then compile then run npm run wasm. Then npm run build and npm run dev should get you a working repro. The WASM instantiation code is in index.svelte and is currently hardcoded to work on my machine. Uncommenting the commented code should reproduce the error nicely. Please let me know if you have questions
http://localhost:3000/
assets/wasm_game_of_life_bg.wasm
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:371:5)
at onParseError (node:internal/url:552:9)
at new URL (node:internal/url:632:5)
at new Request (file:///Users/benwis/Downloads/sveltekit-demo/node_modules/@sveltejs/kit/dist/install-fetch.js:5907:16)
at file:///Users/benwis/Downloads/sveltekit-demo/node_modules/@sveltejs/kit/dist/install-fetch.js:6189:19
at new Promise (<anonymous>)
at fetch (file:///Users/benwis/Downloads/sveltekit-demo/node_modules/@sveltejs/kit/dist/install-fetch.js:6187:9)
at Module.init [as default] (@vite-plugin-wasm-pack@wasm_game_of_life:85:17)
at loadWASM (/src/routes/index.svelte:23:32)
at eval (/src/routes/index.svelte:29:2) {
input: 'assets/wasm_game_of_life_bg.wasm',
code: 'ERR_INVALID_URL'
}
This is rather unlikely to be an issue in SvelteKit, but more likely to be an issue in Vite, so I'm going to go ahead and close this and suggest you use the Vite issue tracker: https://github.com/sveltejs/kit#bug-reporting
Sorry I can't be of more help. We do sometimes fix bugs in Vite if they seem more likely to be hit by SvelteKit users than the average Vite user or important to support a core feature in SvelteKit. But there's hundreds of open issues in the Vite repo and we can't realistically have a duplicate of each of them filed here.
This issue in the Vite issue tracker looks fairly related: vitejs/vite#5075
Describe the bug
This is pretty much identical to this bug: #2480, it appears imports.meta.url is still blank in the "next" target of @sveltejs/kit. The primary difference is that I compile Rust into WASM. The JS wrapper that wraps it includes this function, and import.meta.url appears to be blank, causing an error.
I stumbled on this trying to use the vite-plugin-wasm-pack, which builds successfully, but fails whenever you load the page with the error log described below.
As can be seen in the last error log line, the base is never added to the wasm path file. Providing the full path of the wasm to the init() function fixes the issue.
Reproduction
Here is a the sveltekit demo repo. Note that you have have to have the rust toolchain and wasm-pack installed, then compile then run
npm run wasm
. Thennpm run build
andnpm run dev
should get you a working repro. The WASM instantiation code is in index.svelte and is currently hardcoded to work on my machine. Uncommenting the commented code should reproduce the error nicely. Please let me know if you have questionshttps://github.com/benwis/sveltekit_rust_demo
Logs
System Info
Severity
serious, but I can work around it
Additional Information
While I can hardcode a URL based on a known deployment path, it's a pretty clunky solution. Would love to get that fixed!
The text was updated successfully, but these errors were encountered: