Open acheroncrypto opened 3 months ago
Here's another solution using the latest version of wasm-pack, if you're having the same problem, it might help.
Just set resolvefullyspecified to false in your webpack config https://webpack.js.org/configuration/module/#resolvefullyspecified
This is how I'm applying it in my project
https://github.com/noname0310/babylon-mmd/blob/main/webpack.config.ts#L70-L73
export default (env: any): webpack.Configuration & { devServer?: WebpackDevServerConfiguration } => ({
// ...
module: {
rules: [
{
test: /\.m?js$/,
resolve: {
fullySpecified: false
}
},
]
},
// ...
});
Problem
Upgrading
wasm-pack
to the latest version (0.13.0
) results in the following error with bundlers:https://github.com/RReverser/wasm-bindgen-rayon/blob/a947bdce8ef1e4b5456b349bd5b3763fe2516e25/src/workerHelpers.worker.js#L18-L22
The structure of the
wasm-bindgen
generated package didn't change, but https://github.com/rustwasm/wasm-pack/pull/1061 addedtype: "module"
to thepackage.json
which expects full path imports.Related upstream issue: https://github.com/rustwasm/wasm-pack/issues/1402
Solution
This should probably get fixed from
wasm-pack
's side by introducing an option forwasm-pack build
that changes thetype
used.In the meantime, there are 2 possible immediate workarounds for people who run into this:
type: "module"
from the generatedpackage.json
wasm-pack 0.12.1