Closed BLaZeKiLL closed 1 year ago
This is a known bug. I'll fix it when I have more time.
To workaround it, try disable optimizeDeps
Try v3.2.2
Not sure if I should make this a separate issue, but if I do:
import { greet } from 'wasm'
This gives an error on first page load/full reload. If I remove it and re-add it, HMR seems to fix it, and everything works fine. I'm on v3.2.2
and using wasm-pack
. I've also excluded the wasm
module from optimizeDeps
.
The error is:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".wasm"
wasm-pack creates a
<crate>_bg.wasm.t.ds
file which contains the typedef for the web assembly linear memory and other low-level stuff, to access this memory I am using the following import statementThis works fine in prod mode, but when I start the dev server I get the following error.
As a workaround, I remove the '.wasm' in the end which allows the server to start and then I add it back performing a hot reload which makes the app work normally.
In the error log the ENOENT is trying to look for the file at the wrong location, as it should be under node_modules.
LOG: ➜ Local: http://localhost:4200/ ✘ [ERROR] [plugin vite-plugin-wasm] ENOENT: no such file or directory, open '/Users/codeblaze/src/rust/game-of-life/www/apps/app-game-of-life/src/app/game-of-life/game_of_life_bg.wasm'
This error came from the "onLoad" callback registered here:
Build failed with 1 error: apps/app-game-of-life/src/app/app.element.ts:3:23: ERROR: [plugin: vite-plugin-wasm] ENOENT: no such file or directory, open '/Users/codeblaze/src/rust/game-of-life/www/apps/app-game-of-life/src/app/game-of-life/game_of_life_bg.wasm'