-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Using the production command of SvelteKit deno run build will break the WASM imports. It produces a compiled JS bundle, but it moves the src_wasm_bg.wasm into assets folder, while the compiled logic is looking for it in _app/immutable/chunks where the rest of compiled JS is.
(src_wasm is the name of my rust crate)
http://localhost:1420/_app/immutable/chunks/src_wasm_bg.wasm
[HTTP/1.1 404 Not Found 5ms]
It also produces the following error. When I tried to bypass this by manually importing the WASM from the assets folder, it got blocked due to incorrect MIME types, similarly to the error below.
`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:
TypeError: WebAssembly: Response has unsupported MIME type '' expected 'application/wasm'
During the build process the following notice is also produced:
new URL('src_wasm_bg.wasm', import.meta.url) doesn't exist at build time, it will remain unchanged to be resolved at runtime. If this is intended, you can use the /* @vite-ignore */ comment to suppress this warning.
No matter what I do, I was unable to get WASM to work in production ready environment in SvelteKit. In dev mode it works fine though.
The same errors are produced by both the node and static adapters.