scriptc README

The project's README from github.com/vercel-labs/scriptc. As one markdown file: README.md.

scriptc

Vercel Labs Experiment npm version: scriptc License: Apache-2.0 npm downloads per month: 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

Contributing

See CONTRIBUTING.md for source setup, testing, native artifact builds, and docs development.

scriptc (vercel-labs/scriptc)

Searching Database…

What is this?scriptc is an experimental compiler that turns TypeScript and JavaScript into typed IR, readable C, LLVM IR, native assembly/objects, native executables, or WebAssembly modules, producing standalone binaries that do not need Node.js to run.
Is this a transpiler like tsc, or does it actually produce native binaries?It goes beyond transpiling to JS: scriptc uses the TypeScript compiler only for parsing and type checking, then emits native executables with a small bundled runtime (no Node or JS engine needed), or WebAssembly modules via WASI.
How do I compile a program with it?Write a .ts file, then run scriptc with --emit=ir|c|llvm|asm|obj to get an intermediate artifact, or build a standalone executable directly; `scriptc build --lib --profile ...` creates a self-contained archive.
What do I need installed besides Node?Node.js 24+ is required for everything. --emit=ir|c|llvm needs only Node; --emit=asm|obj uses scriptc's bundled platform helper with no extra compiler needed; full executables need a platform linker driver/SDK (set via SCRIPTCLINKER); WebAssembly/WASI builds additionally require Zig.
Does it support every TypeScript or JavaScript feature out of the box?No - code that cannot compile statically is flagged as a diagnostic, and any-typed code or npm packages need the --dynamic flag, which embeds the quickjs-ng engine. WASI builds also reject anything needing sockets, child processes, OS signals, or filesystem watching.
Which platforms and targets does it support?scriptc targets macOS, Linux, and Windows for native builds, plus WebAssembly via WASI Preview 1; the bundled LLVM-tier helper currently runs on macOS 15+ arm64.
What does the --dynamic flag do?It embeds the quickjs-ng JavaScript engine in the output so the compiler can fall back to interpreting any-typed code or an npm package's JavaScript inside the native binary, without reading node_modules at runtime.
How do I check how much of my code can compile statically?Run scriptc coverage - it reports how much of a program compiles statically and prints a coded diagnostic for every dynamic or unsupported call site.
What is --print=native-link-info for?It emits the compiled object and prints a versioned JSON recipe describing the target, main entry, exact runtime package version, required system libraries, FFI inputs, and ABI marker, which is useful for custom linking setups.
Why does WebAssembly output need Zig instead of the bundled helper?Cross-target WASI/WebAssembly builds go through Zig's bundled WASI libc and LLVM backend to produce a portable WASI Preview 1 module, a different toolchain path from the native macOS/Linux/Windows helper.
What are similar projects?emscripten, compiler, perry, clice, tsrs, blaze, tsx, goose
Size
305.3 MB
Stars
6.6K
Age
4mo
Commits · 90 Days