module broke while using anything from wasm inside the module
🐛 Bug description
I'm using tutorial:
https://rustwasm.github.io/docs/book/game-of-life/hello-world.html
in index.js everything working fine.
The problem is:
after import to any another model (not in index.js) I'm getting err:
Error importing index.js: TypeError: 'AnotherClass' is not a constructor
looks like while using anything from the wasm inside the module -> module class constructor is broke
🤔 Expected Behavior
import inside the module should work the same like in index.js
👟 Steps to reproduce
import anything from wasm.js inside any module (not index.js) and call any wasm method inside any method of module
🌍 Your environment
Include the relevant details of your environment. arch linux, firefox, brave wasm-bindgen = "0.2.82" wasm-pack 0.10.3 rustc 1.63.0 (4b91a6ea7 2022-08-08)
webpack.config.js
const CopyPlugin = require("copy-webpack-plugin");
const path = require('path');
module.exports = {
entry: [ "./another.js", "./bootstrap.js",],
output: {
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: 'development',
experiments: {
asyncWebAssembly: true,
syncWebAssembly: true,
},
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "index.html"),
},
],
}),
],
};
another.js
import { Universe } from "wasm-game-of-life";
export class AnotherClass{
constructor() {
}
any_method(){
const universe = Universe.new(); //it cause error
console.log("some_method");
}
}
index.js
const { AnotherClass } = require("./another.js");
let anotherClass = new AnotherClass();
anotherClass.any_method();
build with: wasm-pack build