wasm-pack-plugin
wasm-pack-plugin copied to clipboard
(0 , _pkg__WEBPACK_IMPORTED_MODULE_0__. my_wasm_function) is not a function
Version: 1.6.0
I started using this plugin and can't call WASM anymore.
webpack config:
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
// ...
config.plugins = [
...config.plugins,
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, "../wasm-build"),
outDir: path.resolve(__dirname, "src/pkg"),
}),
];
The browser shows "ERROR Rust compilation" and the console shows this:
(0 , _pkg__WEBPACK_IMPORTED_MODULE_0__.my_wasm_function) is not a function
In the previous working implementation I was using wasm like this:
package.json dependency:
"wasm": "file:../wasm-build",
And then in the JS files:
const wasmPromise = import("wasm");
const { my_wasm_function } = await wasmPromise;
The reason I want to use this plugin is to be able to import like this:
import {
my_wasm_function
} from "../pkg";
Having the same problem here... I'll let you know if I find a solution!
@arvid220u it's fixed but I honestly don't know what it was. What I did included: overwriting manually the contents of src/pkg
with the build contents, disabling manually the linters in wasm_bg.js
and restarting. Now src/pkg
seems to not update anymore? I'll update if there are new insights.
Hey @arvid220u, @ivanschuetz! Please check rust-wasmpack-loader pacakge, it should fix your porblem.