watever
raw JSON → 0.5.2 verified Sat May 09 auth: no javascript
watever is a bundler and transpiler for WebAssembly text format (WAT) modules, enabling seamless integration with JavaScript. Version 0.5.2, active development. It statically links WAT modules, tree-shakes bytecode, and generates JS wrappers with ESM exports. Unlike other WASM tools, watever focuses on WAT-first development, allowing complex JS imports (e.g., strings, async functions) directly from WAT without glue code.
Common errors
error Error: Cannot find module 'watever' ↓
cause Global install not found or missing dependency
fix
Run 'npm install watever' locally and use 'npx watever'.
error TypeError: logNumber is not a function ↓
cause Forgot to await the async export
fix
Use 'await logNumber();' instead of 'logNumber();'.
error SyntaxError: Unexpected token 'export' ↓
cause Using require() on ESM-only generated module
fix
Use 'import' statement instead of require(), or rename file to .mjs.
Warnings
gotcha All exported functions become async due to WebAssembly.instantiate Promise ↓
fix Always use await when calling exported functions from JS.
breaking Import paths with '#lift' suffix changed semantics ↓
fix Use 'console.log#lift' instead of 'console.log' for lifted functions; see docs.
deprecated The --deno flag is experimental and may be removed ↓
fix Use Node.js for production; check Deno support status before using.
gotcha String encoding expects UTF-8, but WAT data defaults to ASCII ↓
fix Ensure string literals in WAT data sections are UTF-8 encoded, or use escape sequences for non-ASCII.
Install
npm install watever yarn add watever pnpm add watever Imports
- watever CLI wrong
watever input.watcorrectnpx watever input.wat - generated module wrong
const { logNumber } = require('./log-number.wat.js')correctimport { logNumber } from './log-number.wat.js' - default export
import mod from './mod.wat.js'
Quickstart
// Install
npm install watever
// Create WAT file: helloworld.wat
(module
(import "js" "console.log#lift" (func $log (param i32)))
(import "watever/glue.wat" "lift_raw_string" (func $lift_raw_string (param i32 i32) (result i32)))
(data (i32.const 0) "Hello, world!")
(func $hello (export "helloWorld")
(call $lift_raw_string (i32.const 0) (i32.const 13))
call $log
)
)
// Bundle
npx watever helloworld.wat
// Use generated JS module
import { helloWorld } from './helloworld.wat.js';
await helloWorld(); // "Hello, world!"