17 lines
1.3 KiB
Markdown
17 lines
1.3 KiB
Markdown
# rustwasm
|
|
A dead-simple, no-bundling, web-servable Rust/WASM/JS template.
|
|
"Hello, world" style.
|
|
For use in the Rust Ludus backend.
|
|
|
|
### Things to remember
|
|
* Use `js_sys` and `web_sys` for general JS and Web bindings.
|
|
* Ludus, however, speaks in JSON strings and requires a hand-written JS wrapper, which should make the whole JS interop thing much easier.
|
|
- For that, we use `serde_json`.
|
|
* The canonical reference for all this is https://rustwasm.github.io/wasm-bindgen/introduction.html.
|
|
* Look into what thi.ng does with Zig in its WASM packages: https://github.com/thi-ng/umbrella/tree/develop/packages, especially https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api.
|
|
- It's looking like `--target web` is the most appropriate to use in 2024, since they use ES modules and not CommonJS, which is what everything else uses (and necessitates the build step). See https://rustwasm.github.io/wasm-pack/book/commands/build.html.
|
|
- Bun can run the `index.js` file just fine.
|
|
- Deno can, too, but it requires file read access, since that's kind of Deno's thing.
|
|
- Node cannot. See https://rustwasm.github.io/wasm-pack/book/prerequisites/considerations.html. You have to polyfill `fetch` with `node-fetch` (https://github.com/node-fetch/node-fetch).
|
|
* Obligatory: stop trying to make fetch happen.
|