Our great sponsors
-
wrend
A framework-agnostic Rust/WASM + WebGL2 Rendering library, compatible with calling from both Rust and JavaScript on the web.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
I think initially I used their autogenerated templates and other's templates as well, but lately, in my own personal projects, I've started rolling my own Webpack config (v5) with WasmPlugPlugin, which seems to work decently well most of the time. Here's one of my recent frontend crates that is fairly standalone and can be copied if you want a starter template that has been recently updated and has a good chance of compiling / working correctly for you with minimal dependencies: https://github.com/austintheriot/wrend/tree/master/examples/vanilla_rs
Note that the wasm-pack tutorial recommends using the wee_alloc crate. This crate is unmaintained and leaks memory, so it should be avoided. Remove this crate, the default allocator works just fine in WebAssembly.
Now about the choice of the bundler: I don't like webpack and use vite instead. It is blazingly fast, and it requires very little configuration. Getting things like TypeScript, SCSS or React to work correctly and using source maps or hot reloading is a PITA with webpack, whereas it Just Works in vite.
The alternative to wasm-pack is trunk. I've never used it, so I can't tell you how good it is.