Import wasm bug when running on production (nuxt preview)
Environment
- Operating System:
Darwin - Node Version:
v18.9.0 - Nuxt Version:
3.0.0-rc.10 - Nitro Version:
0.5.3 - Package Manager:
[email protected] - Builder:
vite - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-2ebtve-l73ttp?file=nuxt.config.ts
I cannot reproduce it on stackblitz because Nuxt is not running in production there. That's why I've created a repository with a minimal example of the problem here https://github.com/bitlands/wasm-import
Describe the bug
This bug is a follow up thing of https://github.com/nuxt/framework/issues/6703. When I run yarn dev everything works fine and the library can be loaded but when I run yarn run build & yarn run preview the following error appears when I go to the browser console at localhost:3000.
Uncaught (in promise) CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0
Additional context
Thanks for any help!
Logs
No response
See this: https://v3.nuxtjs.org/examples/experimental/wasm#wasm
@516310460 It's basically adding:
export default defineNuxtConfig({
nitro: {
experimental: {
wasm: true
}
},
...
to the nuxt.config.ts right? Unfortunately this produces a new error when I run yarn run build > yarn run preview and go to localhost:3000.
Unhandled Promise Rejection: CompileError: WebAssembly.Module doesn't parse at byte 0: module doesn't start with '\0asm'
@516310460 As a reminder: I use the wasm package for the client not for the server
FYI, you can hit Ctrl-C to stop the dev server in stackblitz and then run npm run build && node .output/server/index.mjs (or hard-code that as the dev command in package.json) to reproduce within stackblitz alone in future issues.
@danielroe Thanks for the tip!
With that I can also reproduce it in stackblitz

@danielroe Any updates or things I could test? I'm not really sure if this is an issue on my side or in Nuxt
@danielroe Thank you for considering this issue. In my opinion this is not a minor bug because it means that as long as this one is not fixed .wasm packages cannot be used with Nuxt 3 but I trust in your evaluation. Thank you!
@danielroe Thank you for considering this issue. In my opinion this is not a minor bug because it means that as long as this one is not fixed .wasm packages cannot be used with Nuxt 3 but I trust in your evaluation. Thank you!
Please be aware that this categorization follows a flow chart. See the docs for more