Kleine Binärdateien, keine versteckten Allokationen über die Grenze, typisierte Bindings.
Constitution — WebAssembly module
Version 1.0.0 · Ratified 2026-11-10
These principles hold for every spec, plan and task of the module. A spec may add rules; it never weakens these.
-
Small binaries. The release
.wasmhas a size budget in the plan (for example 200 KB gzipped), checked in CI afterwasm-opt -Oz. The release profile usesopt-level = "z", LTO andpanic = "abort", and a dependency that breaks the budget needs approval. -
No hidden allocations across the boundary. Large data crosses between JavaScript and Wasm through views into linear memory or caller-provided buffers, not by copying strings and vectors on every call. Each exported function documents who owns the memory it returns.
-
Typed bindings. The JavaScript API is generated by
wasm-bindgenwith TypeScript definitions, and callers never touch raw pointers. The generated.d.tsis checked in CI against a TypeScript usage test. -
Chunky calls, not chatty ones. The boundary is crossed once per unit of work, not once per item. An API that needs a call per element of a large array is redesigned before it ships.
-
Tested in the hosts that use it. Logic is tested with
cargo testnatively, and the bindings run withwasm-bindgen-testin a headless browser and in Node in CI. Errors cross the boundary as typed JavaScript errors, never as a trap.