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
When trying to bundle a WebAssembly module generated from wasm-bindgen via Webpack 5, Node fails to load internal modules (the ones that are provided by Node like util, fs, etc).
I encountered this problem due to the TextEncoder and TextDecoder imports from util. wasm-bindgen generated this code in my JS file:
Bundling this generated code via Webpack 5 and running the bundle with Node 16 resulted in the error:
Error: Cannot find module 'util'
at t (/home/marior/projects/react-wasm/examples/ssr/dist/server/860.index.js:1:68648)
at eval (webpack-internal:///860:7:62)
at Object.860 (/home/marior/projects/react-wasm/examples/ssr/dist/server/860.index.js:1:111)
at __webpack_require__ (/home/marior/projects/react-wasm/examples/ssr/dist/server/index.js:1:8451)
at Function.__webpack_require__.t (/home/marior/projects/react-wasm/examples/ssr/dist/server/index.js:1:8662) {
code: 'MODULE_NOT_FOUND'
}
Manually removing the String.raw from the import fixed it for me.
I assume the String.raw prevents OS compat issues? I have also other imports from JS code snippets that are properly loaded with String.raw, so I think this error just occurs on internal Node modules.
I will send a PR for this to be fixed.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
When trying to bundle a WebAssembly module generated from wasm-bindgen via Webpack 5, Node fails to load internal modules (the ones that are provided by Node like
util
,fs
, etc).I encountered this problem due to the
TextEncoder
andTextDecoder
imports fromutil
.wasm-bindgen
generated this code in my JS file:Bundling this generated code via Webpack 5 and running the bundle with Node 16 resulted in the error:
Manually removing the
String.raw
from the import fixed it for me.I assume the
String.raw
prevents OS compat issues? I have also other imports from JS code snippets that are properly loaded withString.raw
, so I think this error just occurs on internal Node modules.I will send a PR for this to be fixed.
The text was updated successfully, but these errors were encountered: