Rust & WASM in Detail

A Basic wasm-pack

  1. Start a new lib cargo build --lib

  2. Write Code

  3. wasm-pack build

Notes about Crates

  • reqwest doesn’t work


The .js file is generated by wasm-bindgen and contains JavaScript glue for importing DOM and JavaScript functions into Rust and exposing a nice API to the WebAssembly functions to JavaScript. For example, there is a JavaScript greet function that wraps the greet function exported from the WebAssembly module. Right now, this glue isn’t doing much, but when we start passing more interesting values back and forth between wasm and JavaScript, it will help shepherd those values across the boundary.