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
vite-plugin-rsw, is a plugin that lets one use Rust on the web with all the good things that come with Vite(HMR, SSR, ...).
That plugin uses wasm-pack under the hood, which creates javascript glue code and types to easily interface with the wasm file.
The glue code contains the following segment, which seems to create an error in Vite when SSR is enabled in SvelteKit:
asyncfunctioninit(input){if(typeofinput==='undefined'){// not executed if input existsinput=newURL('example-rust-crate-rs_bg.wasm',import.meta.url);// Error: 'new URL(url, import.meta.url)' is not supported in SSR.}constimports={};if(typeofinput==='string'||(typeofRequest==='function'&&inputinstanceofRequest)||(typeofURL==='function'&&inputinstanceofURL)){input=fetch(input);}const{ instance, module }=awaitload(awaitinput,imports);wasm=instance.exports;init.__wbindgen_wasm_module=module;returnwasm;}
If the init function is called with a path to the .wasm file then that line never gets executed but Vite still throws the error. If the line is deleted then Vite does not complain and actually renders the .wasm file in SSR context, but that has to be done by hand.
There should be an ability to ignore such lines and not throw a fatal error at compile time, and only throw the error at run time, if that line is somehow reached, because its demonstrated that the code actually works and its Vite being too harsh.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
Describe the bug
Temporary fix
Relevant line in Vite source that throws the described error
Relevant vite-plugin-rsw issue
Relevant SvelteKit issue
vite-plugin-rsw, is a plugin that lets one use Rust on the web with all the good things that come with Vite(HMR, SSR, ...).
That plugin uses wasm-pack under the hood, which creates javascript glue code and types to easily interface with the wasm file.
The glue code contains the following segment, which seems to create an error in Vite when SSR is enabled in SvelteKit:
If the init function is called with a path to the .wasm file then that line never gets executed but Vite still throws the error. If the line is deleted then Vite does not complain and actually renders the .wasm file in SSR context, but that has to be done by hand.
There should be an ability to ignore such lines and not throw a fatal error at compile time, and only throw the error at run time, if that line is somehow reached, because its demonstrated that the code actually works and its Vite being too harsh.
Reproduction
npm install
npm run dev
and exitnpm run build
Interestingly when trying SSR with
npm run dev
then it works sometimes but sluggishly.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: