Programming WebAssembly with Rust: building Rogue WebAssembly game

I’m trying to build the Rogue WebAssembly game from chapter 4, using the code provided on the website.

In build.sh, the wasm-bindgen command is failing with the stack-trace at [1] below. My version of wasm-bindgen is 0.2.67. I have tried changing the Cargo.toml file to “0.2”, instead of “^0.2”, but the result is the same.

thanks!
Michael

p.s. I am enjoying the book, though it might be better to have the code hosted on GitHub?

[1] -

$ wasm-bindgen target/wasm32-unknown-unknown/debug/roguewasm.wasm --out-dir .
thread 'main' panicked at 'remaining data [23]', [SNIP]/wasm-bindgen-cli-support-0.2.67/src/descriptor.rs:109:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: std::panicking::begin_panic_fmt
   8: wasm_bindgen_cli_support::descriptors::execute
   9: wasm_bindgen_cli_support::Bindgen::generate_output
  10: wasm_bindgen_cli_support::Bindgen::generate
  11: wasm_bindgen::main
  12: std::rt::lang_start::{{closure}}
  13: std::rt::lang_start_internal
  14: main
2 Likes

With wonderful help from friends [1], here are steps that enabled the jsint_roguewasm example on my machine:

  • edit index.js to import from ./pkg/roguewasm instead of ./roguewasm
  • edit src/lib.rs to import from ../index instead of ./index
  • in build.sh, replace the wasm-bindgen command with wasm-pack build

[1] - Many thanks to Chris Macrae and Evan Theriault

3 Likes