SkillAgentSearch skills...

Watr

Light & fast WAT compiler

Install / Use

/learn @dy/Watr
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<img src="./watr.svg" height="16"> watr npm test

Light & fast WAT compiler

docs  ·  demo

<!-- _Use for_: backends, compilers, DSLs, codegen, dev tools -->

Usage

import watr, { compile, parse, print } from 'watr'

// compile to binary
const binary = compile('(func (export "f") (result f64) (f64.const 1))', {
  polyfill: false, // transform newer features to MVP
  optimize: true   // fold constants, treeshake, eliminate dead code ...
})
const module = new WebAssembly.Module(binary)
const { f } = new WebAssembly.Instance(module).exports

// parse
parse('(i32.const 42)') // ['i32.const', 42]

// print
print('(module(func(result i32)i32.const 42))') // (module\n  (func (result i32)\n  ...

// instant wasm function
const { add } = watr`(func (export "add") (param i32 i32) (result i32)
  (i32.add (local.get 0) (local.get 1))
)`
add(2, 3) // 5

// instant wasm: interpolate, auto-import ...
const { test } = watr`(func (export "test") (call ${console.log} (i32.const 42)))`
test() // logs 42

CLI

npx watr input.wat              # → input.wasm
npx watr input.wat -o out.wasm  # custom output
npx watr input.wat --print      # pretty-print
npx watr input.wat --minify     # minify
npx watr input.wat --optimize   # fold, treeshake, deadcode
npx watr input.wat --polyfill   # newer features → MVP

Metrics

Used by

  • jz – minimal static JS subset
<p align="center"><a href="https://krishnized.github.io/license">ॐ</a></p>
View on GitHub
GitHub Stars56
CategoryDevelopment
Updated5d ago
Forks0

Languages

JavaScript

Security Score

85/100

Audited on Mar 29, 2026

No findings