Skip to content

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

@ivnsch

Description

@ivnsch

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";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions