vite-plugin-wasm icon indicating copy to clipboard operation
vite-plugin-wasm copied to clipboard

Top level await support

Open ESchouten opened this issue 1 year ago • 4 comments

I get the following error: This require call is not allowed because the imported file "vite-plugin-wasm-namespace:/node_modules/.pnpm/@[email protected]/node_modules/@foxglove/wasm-bz2/wasm/module.wasm" contains a top-level await

Is there any way to enable top-level await support for wasm dependencies?

ESchouten avatar Jan 26 '24 16:01 ESchouten

Seems the error is thrown by esbuild?

Menci avatar Jan 26 '24 16:01 Menci

Second this, having the exact same problem:

The file "node_modules/wasm-brotli/wasm_brotli_browser.js" imports the file
 "vite-plugin-wasm-namespace:/<removed>/node_modules/wasm-brotli/wasm_brotli_browser_bg.wasm"
 here:

   node_modules/wasm-brotli/wasm_brotli_browser.js:1:22:
     1 │ import * as wasm from './wasm_brotli_browser_bg.wasm';
       ╵                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 The top-level await in
 "vite-plugin-wasm-namespace:/<removed>/node_modules/wasm-brotli/wasm_brotli_browser_bg.wasm"
 is here:

   vite-plugin-wasm-namespace:/<removed>/node_modules/wasm-brotli/wasm_brotli_browser_bg.wasm:44:27:
     44 │ const __vite__wasmModule = await initWasm({ "./wasm_brotli_browser.js": { __wbindgen_string_new: __vite__wasmImport_0_0, __wbindgen_rethrow: __vite__wasmImport_...
        ╵                            ~~~~~


This error is encountered after running vite server, no fail on build

nick-benyo avatar Feb 10 '24 02:02 nick-benyo

Same. Error when dev, but no error when build. Also using vite-plugin-top-level-await

inyellowbus avatar Mar 06 '24 12:03 inyellowbus

same issue here

khanhhaquang avatar Sep 18 '24 07:09 khanhhaquang