JS Component Tools
JS-compiled CLI & API versions of some of wasm-tools, wit-bindgen host js and binaryen opt & wasm2asm.
Note: This is an experimental prototype without any maintenance guarantees.
Install
CLI
npm install -g js-component-tools
The CLI is then available via the jsct --help
command.
Usage: jsct <command> [options]
WebAssembly Component Tools
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
wit [options] <component-path> [wasm2wit] decode the world WIT for a WebAssembly Component
host [options] <component-path> [wit-bindgen host js] host a WebAssembly component for JavaScript execution
opt [options] <component-file> optimizes a Wasm component, including running wasm-opt Binaryen optimizations
print [options] <input> [wasm-tools print] prints the WebAssembly binary textual form
parse [options] <input> [wasm-tools parse] parses the Wasm text format
help [command] display help for command
API
npm install js-component-tools
import { host } from 'js-component-tools';
import { readFile } from 'fs/promises';
const component = await readFile('./component.wasm');
const compiledFiles = await host(component, { optimize: true, minify: true });