`scriptc coverage` now lists every WebAssembly module whose bytes the build can see, with its size, whether it validates, its function, import and export counts, and the WebAssembly proposals it uses. Nothing is translated yet; builds are unchanged. - packages/compiler/src/wasm/binary.ts decodes and validates a module in plain TypeScript (the native compiler compiles it too) at the feature level scriptc means to translate: the MVP plus sign-extension, non-trapping float-to-int, bulk memory, multi-value, mutable globals, reference types and extended constant expressions. Where WebAssembly 3.0 and V8 relaxed a 2.0 rule (global initializers reading defined globals, memory indices), it follows V8, the behavior oracle. Modules that use SIMD, threads, exception handling, tail calls, function references or GC, memory64 or multiple memories still decode, and are reported as needing that proposal instead of as invalid. - packages/compiler/src/wasm/discover.ts finds modules from four sources: paths the compiler resolves from the source text (require.resolve, createRequire(...).resolve, import.meta.resolve, new URL(..., import.meta.url), __dirname joins), inline base64 and byte-array literals, the .wasm files of reached packages whose code mentions WebAssembly, and a `scriptc.wasm` list in package.json or the new coverage-only `--wasm <file>` flag. Modules are reported once, by SHA-256, with every source that found them; module files are input probes of the coverage verdict cache. The JSON envelope (--print=diagnostics) carries the same records under `wasmModules`. Evidence: packages/compiler/test/wasm-spec.test.ts runs the decoder over the 3,017 distinct binary modules of the WebAssembly 2.0 core test suite (without SIMD) and the extended-const proposal's tests, generated by gen-wasm-spec-cases.mjs with wabt's wast2json, and requires V8's verdict for each; 8,000 seeded mutations of those modules must also agree with V8, as must undici's inline llhttp modules (scalar valid, SIMD reported) and es-module-lexer's. src/wasm/binary.test.ts checks each feature and each error class against V8. On the survey's real modules the decoder agrees with V8 for quickjs-wasi (637 KB, 36 ms) and photon (1.9 MB, 121 ms). tests/coverage-fixtures/wasm pins the four discovery sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scriptc
scriptc compiles TypeScript and JavaScript to native executables and WebAssembly. It uses the types checked by the TypeScript compiler to generate machine code, and the output runs without Node.js installed. npm packages your program imports compile along with it. Code scriptc can't compile is reported at build time with a diagnostic and, where available, a rewrite hint.
scriptc is experimental and supports a subset of JavaScript, TypeScript, and Node.js APIs. Run scriptc coverage on an existing program to see how much of it compiles, and see the limitations and Node.js compatibility reference for details.
Installation
Install with Node.js 24 or later and npm:
$ npm install -g scriptc
The installed compiler runs natively on macOS, Linux, and Windows. Node.js is needed only to install it and to run WASI modules with scriptc run. Standalone compiler archives are also available from GitHub Releases.
Building executables requires a linker and the platform SDK or sysroot. See the quickstart for prerequisites and platform support for host requirements, cross-compilation, and WebAssembly.
Build a program
Create hello.ts:
const who = process.argv.length > 2 ? process.argv[2] : "world";
console.log(`hello, ${who}`);
scriptc run compiles the file and runs the result:
$ scriptc run hello.ts
hello, world
scriptc build writes an executable:
$ scriptc build hello.ts -o hello >/dev/null
$ ./hello scriptc
hello, scriptc
These examples use POSIX shell syntax. On Windows, build hello.exe and run it with .\hello.exe.
Use scriptc coverage hello.ts to check what compiles before you build. See coverage reports for details.
Use Node APIs
Supported Node APIs compile to the native runtime. For example, server.ts:
import { createServer } from "node:http";
const server = createServer((req, res) => {
res.setHeader("content-type", "application/json");
res.end(JSON.stringify({ path: req.url }));
});
server.listen(8080, () => {
console.log("listening on http://localhost:8080");
});
$ scriptc build server.ts -o server >/dev/null
$ ./server
listening on http://localhost:8080
Use npm packages
npm packages compile into the executable with your code, so it doesn't read node_modules at runtime.
Create cli.ts:
import pc from "picocolors";
console.log(pc.green("hello from scriptc"));
$ npm install picocolors
$ scriptc build cli.ts -o cli >/dev/null
$ ./cli
hello from scriptc
Package support is partial. See npm dependencies for which packages compile and how to check them.
Documentation
- Introduction: what scriptc is and what you can build.
- Quickstart: installation and your first executable.
- Coverage reports: check whether an existing program compiles.
- Platform support: cross-compilation and WebAssembly.
- CLI reference: commands, options, and output formats.
- Native program objects: use compiler output in external builds.
- Native FFI: call C ABI functions from compiled programs.
- WebAssembly modules: build and embed WASI modules.
- Examples: programs and integration examples in this repository.
Contributing
See CONTRIBUTING.md for source setup, testing, native artifact builds, and docs development.