rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript

Home Page:https://rustwasm.github.io/docs/wasm-bindgen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

export names as they are

womeier opened this issue · comments

Background

I'm compiling multiple programs to Wasm and want to run them with the same Node.js-based runner script, my setup is similar to the following. The generated Wasm binary should import a print function write_string so it can write strings to stdout:

#[wasm_bindgen]
extern "C" {
  fn write_string(s: &str);
}

#[wasm_bindgen]
pub fn main() {
  write_string(&format!("{:?}", demo1()))
}

This generates a Wasm module expecting a function import under the name __wbg_writestring_6842f18ee0be6fba, where the hash-value changes depending on the concrete source program.

Question

Is there an option so wasm-bindgen doesn't generate this hash-value in the first place?

I currently use a script to get rid of that, which works but is a bit unpleasant,
I couldn't find a flag for that in the documentation.

Thanks!