bazelbuild / bazelbuild/rules_rust
Add WebAssembly example embedded in web page
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
I'd like to compile Rust into WebAssembly, roll it up into a single WebAssembly (and/or JS file) and run it in a web browser. I've been having some trouble getting it to run.
(`rust_wasm_bindgen` generates JS / WASM with imports from other modules.)
I'm trying to use `rollup_bundle` from rules_nodejs, with `@rollup/plugin-wasm`, and am getting this error message:
```
bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen.js → bazel-out/k8-fastbuild/bin/wasm/bundle...
(!) Missing exports
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen_bg.js
memory is not exported by bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen_bg.wasm
9: let cachegetUint8Memory0 = null;
10: function getUint8Memory0() {
11: if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
^
12: cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
13: }
bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen_bg.js
memory is not exported by bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen_bg.wasm
10: function getUint8Memory0() {
11: if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
12: cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
^
13: }
14: return cachegetUint8Memory0;
bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen_bg.js
memory is not exported by bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen_bg.wasm
10: function getUint8Memory0() {
11: if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
12: cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
^
13: }
14: return cachegetUint8Memory0;
bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen.js
__wbindgen_start is not exported by bazel-out/k8-fastbuild/bin/wasm/main_wasm_bindgen_bg.wasm
1: import * as wasm from "./main_wasm_bindgen_bg.wasm";
2: export * from "./main_wasm_bindgen_bg.js";
3: wasm.__wbindgen_start();
^
```
Contributor guide
Assessment
This issue has not been assessed yet.