Post

I don't know how I survived this long recompiling WASM binary after every change but I finally wrote a mini Vite plugin for HMR. Now when I change anything and save the file, WASM module is automatically compiled and reloaded.

0 reposts7 likes

For me it's usually for simulations where low level code with manual memory control makes a difference between unusable and real time. Not long ago I played with triangulations: tchayen.com/handmade-pat... For the same data, the most optimized JS code I could write took 900ms, Zig version 25ms.

I have a 'wasm' command declared in package.json which compiles the binary and places it in web/bin. Plugin is listening for changes in zig/ and runs that command. Finally handleHotUpdate() notices that a *.wasm file changed and sends HMR to the browser.