On hosts that can fork, the native compiler now emits a large module's function bodies on worker processes (SCRIPTC_EMIT_WORKERS, 4 by default). The function list splits into contiguous ranges, each emitted by a forked child of the emitter, and the ranges merge in function order into the text one emitter gives. A range whose worker fails is emitted in the parent. Modules under 2,000 functions, Node and Windows keep the serial path. A range's emitter records an ordered journal (emit-journal.ts): - every helper it numbers from a counter (the dyn conversions and matchers, message listeners and readers, JSON writers, publication walkers, stream adapters and resolve thunks), recorded when its number is taken, with the entry point and arguments that create it; - the first request of each key of a module-level table (declarations, literals, C strings, unit and absent instances, retype guards, regex and template-strings instances, map descriptors, alias tags) made outside a helper's definition; - unkeyed sites (inline caches, speculative loop sites) taken outside a definition. A speculative loop site's global is now `@sc_spec_bails_N`, named like the other numbered sites. The merging emitter replays each range's journal in order. Replay calls the same entry points, so every helper gets the number and definition the serial emission gives it, and table entries land in the serial order. The range's text is then renamed to the merged numbers in one pass. Sets and flags the ranges set (await callees, function values, RC helper requests) merge after the replay. LlvmTargetOptions.functionChunks runs the same merge in one process, for tests. The fork, exit, wait and lock primitives come from the native host (host.c, process-fork.ts); the native compiler passes them to the emitter as LlvmTargetOptions.forkPrimitives.
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.