scriptc and the End of the TypeScript Runtime

How Vercel Labs is compiling ordinary TypeScript into native binaries, using QuickJS only as an island when static lowering runs out of road.

9 min read • View on GitHub • More from vercel-labs

A wide mechanical scene shows TypeScript source entering a press that stamps out a small native binary. A side chamber contains a tiny QuickJS engine on an island, connected by a narrow valve that opens only for spillover code. The image explains that scriptc routes some code to native output, some to a contained fallback, and rejects the rest.
Scriptc is not a single-path compiler. It is a routing system that spends runtime only where the compiler cannot safely erase it.
Key Takeaways

scriptc tries to remove the runtime, not just shrink it

Most TypeScript tools promise a smaller deployable artifact. scriptc goes after something harsher: the runtime itself. It wants ordinary TypeScript, but it only keeps the parts it can safely lower into native code.

That is why the project’s core idea is not “compile TS to native.” It is “route each piece of TS to the cheapest safe execution lane.” When the compiler can prove the path, it emits native code. When it cannot, it may drop into QuickJS. When neither is safe, it rejects the construct with a specific diagnostic.

I compiled 𝚟𝚎𝚛𝚌𝚎𝚕 CLI TypeScript to native with 𝚜𝚌𝚛𝚒𝚙𝚝𝚌. Incredible. ✓ Resulting binary size: 1.28mb ✓ Startup overhead: 1.5ms (mean) ✓ Compiles in 2.94s (mean) ✓ Uses 𝚗𝚘𝚍𝚎:𝚑𝚝𝚝𝚙𝚜, 𝚗𝚘𝚍𝚎:𝚏𝚜, 𝚗𝚘𝚍𝚎:𝚙𝚊𝚝𝚑, 𝚗𝚘𝚍𝚎:𝚘𝚜, 𝚗𝚘𝚍𝚎:𝚌𝚛𝚢𝚙𝚝𝚘 https

Guillermo Rauch, rauchg, 718,367 followers · @rauchg on X

The real product is a three-lane execution model

The routing model is the whole bet. Scriptc classifies code first, then decides whether it can erase the runtime, contain it, or refuse it.

ModelRuntime included?Compatibility strategyFallback behaviorDeveloper tradeoff
scriptcNo, unless neededStatic lowering first, QuickJS island secondRejected constructs get explicit diagnosticsNative binaries with selective escape hatches
Node.js / BunYesBroad runtime compatibilityNo fallback needed because the VM is always thereMaximum ecosystem coverage, heavier startup and size
AssemblyScriptNoSubset-first disciplineUnsupported language features are outside the modelCleaner compilation, narrower TypeScript surface
PorfforNoSpec-oriented executionDifferent compatibility philosophy, no embedded general runtimeStrong “no runtime” story, less Node-shaped compatibility
Go / ZigNoNative binary baselineNot a TS compiler model at allGreat systems fit, but you leave TypeScript behind

This comparison is the useful frame. Scriptc is not trying to beat Node at being Node, and it is not trying to out-purity AssemblyScript or Porffor. It is trying to make ordinary TypeScript usable when you care about startup time, binary size, and deployment shape.

Why the compiler is fast enough to be useful

The hard part is not codegen. It is sitting on top of the TypeScript compiler API without drowning in overhead. Scriptc’s frontend uses a custom ts7 adapter, batching, and memoization so the checker becomes a serviceable dependency instead of the bottleneck.

That matters because the compiler is doing more than syntax translation. It is repeatedly asking the TypeScript type system questions, then turning those answers into routing decisions. If that loop is slow, the whole product collapses into a research demo.

// The point is not the syntax, but the compile-time evaluation boundary.
const port = comptime(() => process.env.PORT ?? "3000");

export function main() {
  return `listening on ${port}`;
}
A close-up workbench shows TypeScript statements entering a lowering jig. One piece is stamped static, one is routed through a small tunnel into a miniature island, and one is marked rejected with a warning tag. The image explains how the compiler classifies expressions instead of failing on the first unsupported construct.
Scriptc does not stop at the first unsupported feature. It keeps lowering, classifies what it can, and turns the remainder into actionable feedback.

Lowering TypeScript into a typed IR changes the rules

The lowering pipeline is where the project stops looking like a wrapper around tsc and starts looking like a compiler. TypeScript is converted into a typed intermediate representation, including nodes that know whether they can become native code, need a dynamic island, or should be rejected.

That design choice is subtle but important. Instead of treating unsupported code as a dead end, the compiler can keep going and build a coverage report. The result is broader insight into a codebase, not just a yes or no answer.

It also explains the project’s stance on type safety. In scriptc, a cast is not just documentation. It is something the runtime can verify at the boundary, which turns the compiler into a contract enforcer rather than a blind transporter of type annotations.

The fallback is the bet

The fallback is not a compromise the project tries to hide. It is the strategic move. Most projects in this space choose one of two uncomfortable extremes: enforce a tiny subset, or ship a full JavaScript engine. Scriptc chooses a third option.

That third option matters because the npm ecosystem is messy. Untyped JavaScript still exists everywhere. A selective island model gives scriptc a way to keep moving through that mess without pretending the ecosystem has already become perfectly typed.

ApproachWhat it optimizes forWhat it gives upWhat scriptc does differently
Runtime-firstCompatibilityBinary size and startup costKeeps runtime off the main path
Subset-firstStatic guaranteesEcosystem breadthAccepts more TypeScript and quarantines the rest
No-runtime purismSimplicity of storyPractical compatibilityUses QuickJS only where the compiler needs an escape hatch
Generic native languagePerformance and tooling maturityTypeScript developer workflowKeeps TypeScript as the source language

That is also why the project feels more like a systems design argument than a syntax compiler. It is saying that the runtime should be treated as a scarce resource, not an assumption.

What scriptc suggests about TypeScript’s future

The deeper implication is not that TypeScript replaces Rust or Go. It is that TypeScript can sometimes be treated as a source language for binaries, CLIs, and narrow services without dragging a full VM behind it.

That is a different future from the one most JavaScript-adjacent tools have assumed. In that future, the compiler is not just a type checker with output. It is an execution planner, deciding which code deserves native treatment and which code needs a contained fallback.

If scriptc holds up, the interesting question stops being whether TypeScript can run everywhere. It becomes where the runtime is actually worth paying for.