MDN has docs on the raw JavaScript usage of WASM, along with guides on building the WASM module (spoilers, eventually they're going to tell you to use npm to build the JavaScript side). It's a handy start if you want to build the JavaScript side yourself, so you know what is actually getting transferred and when, but it's quite a journey to get to anything actually useful and usable.
IIRC, Rust wasm modules export a single Memory object as memory
, and you can directly call any #[no_mangle] pub fn
(don't use #[wasm_bindgen]
since that needs specific JS on the other side) taking and returning only 32 and 64 bit number types (eg u32, f64, ...).
With those two things and the basic JavaScript API, you can build anything you like, by passing pointers as indexes into memory
, exporting memory allocation functions, copying data in and out, and creating reference tables and index encoding schemes to handle preserving object identities so you can call methods, etc.. it's a lot of work!