Over the weekend I started playing with wasm-bindgen which,
allows JS/wasm to communicate with strings, JS objects, classes, etc, as opposed to purely integers and floats.
Notable features of this project includes:
Exposing Rust structs to JS as classes
Exposing Rust functions to JS
Managing arguments between JS/Rust (strings, numbers, classes, objects, etc)
Importing JS functions with richer types (strings, objects)
Importing JS classes and calling methods
Receiving arbitrary JS objects in Rust, passing them through to JS
Catching JS exceptions in imports
I began building a simple safe_app_wasm library but ran into compilation issues having to do with dependency crates that only support Windows or Linux target families, when my target is
wasm32-unknown-unknown, summarised in this issue.
You’ll see that these two crates memmap and fs2 that we rely on need either a Windows or Linux target.
Even when rust-wasm decides how to treat
wasm32-unknown-unknown target, it looks like 3rd party crates will still need to implement wasm support.
wasm-bindgen is much cleaner than my experiments using Neon and I think it would be worthwhile to spend time either opening issues in crates that we want supported or to open PR’s on those crates to implement