Files
scriptc/packages/cli
Chris Tate d426960f45 Make Cipheriv and Decipheriv Transforms and accept function stages anywhere in pipeline()
Cipheriv and Decipheriv values are Transforms, as in Node: they can be
written and ended, piped into, used as pipeline() and stream/promises
pipeline stages, composed, read, iterated with for await, read by
stream/consumers, passed to finished(), and listened to, and their stream
properties read as in Node. Each chunk goes through the cipher's
update(), and the end pushes final() or reports its error through
'error'; writing after final() throws out of write(). The stream unit
builds a cipher's Transform on its first stream use from operations the
cipher's handle provides (ScrDynHandleOps.transform), so programs that
use ciphers without streams link as before. The cipher is a
collector-headered object behind a traced handle: its Transform's steps
hold it, and the pair is reclaimed as a cycle. Through untyped values, in
a program that uses streams, a cipher's stream properties and its on,
once, off, pipe, unpipe, read, pause, resume, setEncoding, write, end,
destroy, cork and uncork members run on its Transform; other stream
members throw a coded SC2020 error.

A Transform holds a write's callback while its readable side is at the
high-water mark and runs it at the next read, and runs it on a tick once
the readable side has ended, as Transform._write does. write() on a
PassThrough, a Transform, a Hash or a cipher used to return true however
much the readable side buffered. zlib streams applied the rule already
and keep their timing.

pipeline() accepts function stages anywhere among its streams, so runs of
async generator stages can sit on both sides of a stream. A stage can be
named by a function declaration, or a const bound to a function
expression, that nothing reassigns; its body lowers again at the
pipeline with its source typed by the pipeline. The source can also be
an array, a string, a synchronous generator object, or a synchronous
generator function without parameters: an async generator steps the
source's iterator and yields each element, and the next stage receives
each element on the same tick as with Node's for await over the source.
The runtime's function-stage entry points take a bitmask of the function
positions and one (next, read, return) helper triple for each generator
pumped into a stream, so RUNTIME_ABI_VERSION is now 25. In JavaScript,
the chunks a stage receives from the previous stage's generator read as
the strings or Buffers it yields, so their string and Buffer methods
compile.

Corpus 7055-7059 cover cipher streams in TypeScript and JavaScript, their
errors, close order and backpressure, the pipeline stages and sources
with their tick order, and Transform backpressure.
2026-10-22 01:55:38 -05:00
..
2026-07-22 18:08:04 -05:00
2026-10-21 09:51:40 -05:00
2026-07-22 18:08:04 -05:00

scriptc

Compile TypeScript and JavaScript to native executables or WASI WebAssembly modules that run without Node.js installed.

$ cat fib.ts
function fib(n: number): number {
  return n < 2 ? n : fib(n - 1) + fib(n - 2);
}
console.log(fib(30));

$ scriptc run fib.ts
832040

$ scriptc build fib.ts -o fib >/dev/null && ./fib
832040

scriptc compiles the same TypeScript you run on Node.js, type-checked by the TypeScript compiler. npm packages your program imports compile along with it. Code scriptc can't compile fails the build with an error code and, where available, a rewrite hint.

scriptc is experimental. See the limitations and the Node.js compatibility reference.

Install

$ npm install -g scriptc

npm installs the native compiler for your platform (macOS, Linux, or Windows). Node.js 24 or later is needed to install it and to run WASI modules with scriptc run; compiling and running executables doesn't need Node.js.

Building executables needs a linker and the platform SDK or sysroot, such as the Xcode Command Line Tools on macOS. Set SCRIPTC_LINKER to choose the linker driver. --emit=ir|llvm|asm|obj needs no external tools. See the quickstart for details.

Commands

  • scriptc build <file.ts>: compile to a native executable or another artifact selected with --emit.
  • scriptc run <file.ts>: compile and run.
  • scriptc coverage <file.ts>: report what compiles, and explain what doesn't.
  • scriptc build --lib --profile <profile.json>: compile a static library, or a Wasm reactor on wasm32-wasi.

See the CLI reference for every option.

Cross-compilation and WebAssembly

Set SCRIPTC_TARGET to build for another platform, for example SCRIPTC_TARGET=aarch64-linux-gnu.2.36 or SCRIPTC_TARGET=wasm32-wasi. Install the matching @scriptc/runtime-<target> package in your project, at the same version as scriptc --version, or set SCRIPTC_RUNTIME_PACK to a runtime pack directory. See platform support and WebAssembly modules.

Native code

Call C functions by declaring their signatures in TypeScript and binding them to C symbols in a manifest passed with --ffi <manifest.json>. See the Native FFI guide.

Build cache

Builds reuse a bounded persistent cache. Set SCRIPTC_NO_CACHE=1 to bypass it or SCRIPTC_CACHE_DIR to choose its location.

Docs: scriptc.dev