Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(0 , _pkg__WEBPACK_IMPORTED_MODULE_0__. my_wasm_function) is not a function #139

Open
ivnsch opened this issue Sep 7, 2022 · 3 comments

Comments

@ivnsch
Copy link

ivnsch commented Sep 7, 2022

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";
@arvid220u
Copy link

Having the same problem here... I'll let you know if I find a solution!

@ivnsch
Copy link
Author

ivnsch commented Sep 10, 2022

@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.

@yeskiy

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants