watr is a lightweight, zero-dependency WAT (WebAssembly Text format) compiler written in JavaScript. Current stable version is 4.5.0, with frequent releases adding support for upcoming WebAssembly proposals. It compiles WAT to binary (wasm), parses into AST, pretty-prints, minifies, optimizes, and polyfills newer features to MVP. Key differentiators: small bundle size (~84KB minified, ~24KB gzipped), high throughput (~4460 op/s vs 700-2200 for alternatives), spec-complete with GC, exception handling, and stack switching, built-in CLI, and a unique tagged template literal for instant wasm exports with JS interop.
npm install watrNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Compiles WAT to binary, parses to AST, pretty-prints, and uses tagged template for instant wasm with JS interop.
Update to use compile(source, options) which returns Uint8Array synchronously. If you used callbacks, switch to promise or synchronous usage.
Use interpolations for imports or constants only; do not embed dynamic code generation via string concatenation inside template literal — use compile() with string building instead.
Use polyfill: false/true for now; check changelog for future changes.
Use dynamic import: const watr = await import('watr'); or switch to ESM.Validate WAT against the WebAssembly spec; use the official test suite or watr's parse to check.
Use `import watr from 'watr'` (ESM) or `const watr = await import('watr')` in Node with ESM enabled. If using TypeScript, ensure module resolution is 'node' or 'node16' and 'esModuleInterop' is true.Use `parse(yourWat)` to get detailed error with line/column. Check the WAT against the WebAssembly spec or use watr's print with formatting to debug.
Use watr`...` (backticks) not watr('...'). For direct compilation, use the named `compile` import.Upgrade to watr >=3.0.0 (currently 4.5.0) which fully supports reference types and all proposals.
No dependency data recorded yet.