rust-native-wasm-loader icon indicating copy to clipboard operation
rust-native-wasm-loader copied to clipboard

wasm-bindgen not found during webpack chaining

Open Zireael opened this issue 6 years ago • 2 comments
trafficstars

Hi I'm getting error (looks like it can't find wasm-bindgen):

image

I have wasm-bindgen installed on my system (can compile .rs into .wasm with [wasm-pack build]).

I use Vue cli, not sure if that matters (it's just a wrapper for webpack). Would you have any ideas to solve this? I can use .wasm files built with wasm-pack, but can't .rs from webpack loader chaining.

Vue Webpack chain config:

    config.module
      .rule("Rust")
      .test(/\.rs$/)
      .use("wasm-loader")
      .loader("rust-native-wasm-loader")
      .options({
        release: true
      });

.rs import:

import loadAdd from "@/js/wasm/hello_world/hello_world.rs";

loadAdd().then(result => {
  const add = result.instance.exports["add"];
  console.log("return value was", add(2, 3));
});

I tried using the [wasm-bindgen experimental support] webpack config provided on your page a well, but getting same error.

Zireael avatar Apr 22 '19 21:04 Zireael

I got the same problem, wasm-bindgen not found. even remove wasm2es6js option. image image

If I build it by wasm-pack, everything is good.

zhangjsff avatar Apr 26 '19 08:04 zhangjsff

Solved after install wasm-bindgen-cli by cargo.

It's because I'm new on Rust.

zhangjsff avatar Apr 26 '19 09:04 zhangjsff