59/59 tests passing | Active Development

Compile TypeScript to
Native Executables

Perry is a native TypeScript compiler written in Rust that compiles your TypeScript directly to machine code. No runtime required.

terminal

$ perry build main.ts

Compiling main.ts...

✓ Built executable: main (2.3 MB)

$ ./main

Hello, World!

2-5 MB
Binary size
0 ms
Startup time
27+
Native npm packages
100%
Type-safe

Why Perry?

Everything you need to compile TypeScript to native applications

No Runtime Required

Produces standalone native executables. No Node.js, no V8, no runtime dependencies. Just a single binary that runs anywhere.

Fast Compilation

Direct TypeScript to native code compilation using SWC for parsing and Cranelift for code generation. No intermediate JavaScript.

Small Binaries

Output binaries are typically 2-5MB. With optional V8 runtime for JS npm packages, 15-20MB. Ship less, deploy faster.

Type-Safe

Leverages TypeScript's type system for optimization. Types enable better code generation through monomorphization.

Comprehensive Standard Library

Built-in native implementations of fs, path, crypto, os, Buffer, child_process, and more. Use familiar Node.js APIs.

Optional V8 Runtime

Need to use a pure JavaScript npm package? Enable the V8 runtime flag for full npm ecosystem compatibility.

Write TypeScript, Ship Native

Use familiar TypeScript syntax and APIs. Perry handles the rest.

hello.ts
// hello.ts
const greeting = "Hello, World!";
console.log(greeting);
 
// Compiles to ~2MB native executable
// No runtime needed!
$ perry build hello.ts
Native binary

Performance Comparison

Native compilation delivers unmatched efficiency

Metric
Perry
Node.jsBun
Binary Size2-5 MB~80 MB~90 MB
Startup Time~1 ms~30 ms~10 ms
Runtime DependenciesNoneNode.jsBun
Memory OverheadMinimalV8 + GCJSC + GC
Binary SizeLower is better
Perry
5 MB
Node.js
80 MB
Bun
90 MB

Get Started

Install Perry and start compiling TypeScript to native executables

1Installation

terminal
$ git clone https://github.com/aspect-build/perry.git
$ cd perry
$ cargo build --release

Requires Rust toolchain. Binary will be at target/release/perry

2Usage

Compile a file
perry build main.ts

Compiles main.ts to a native executable

Custom output
perry build main.ts -o myapp

Specify the output executable name

With V8 runtime
perry build main.ts --enable-js-runtime

Enable V8 for JavaScript npm package compatibility

Check compatibility
perry check ./src

Validate TypeScript code for native compilation

Feature Support

Comprehensive TypeScript and Node.js API coverage

Core Language

  • Numbers64-bit floating point (f64)
  • StringsUTF-8, all common methods
  • Booleanstrue/false, logical operators
  • ArraysTyped and mixed-type arrays
  • ObjectsObject literals and field access
  • BigInt256-bit integer support
  • EnumsNumeric and string enums

Functions

  • Function DeclarationNamed functions
  • Arrow Functions() => {} syntax
  • Default ParametersParameters with defaults
  • Rest Parameters...args syntax
  • ClosuresIncluding mutable captures
  • Higher-Order FunctionsFunctions as arguments/returns
  • Async/AwaitAsync function support

Classes

  • Class DeclarationBasic class syntax
  • ConstructorsWith parameters
  • Private Fields (#)ES2022 #privateField syntax
  • Static Methods/FieldsClass-level members
  • Getters/Settersget/set accessors
  • Inheritanceextends keyword
  • Super Callssuper() constructor calls

Type System

  • Type AnnotationsExplicit type declarations
  • Type InferenceAutomatic type detection
  • GenericsMonomorphization (like Rust)
  • InterfacesInterface declarations
  • Union Typesstring | number support
  • Type Guardstypeof operator
  • Type Aliasestype X = ... declarations

Standard Library

  • fsreadFileSync, writeFileSync, existsSync, etc.
  • pathjoin, dirname, basename, extname, resolve
  • cryptorandomBytes, randomUUID, sha256, md5
  • osplatform, arch, hostname, memory info
  • Bufferfrom, alloc, toString, slice, copy
  • child_processexecSync, spawnSync
  • JSON/Math/DateFull implementations
Full Support
Partial

27+ Native npm Packages

Popular npm packages reimplemented in native Rust. No npm install, no node_modules, just fast native code.

Database

mysql2pgmongodbbetter-sqlite3ioredis

Security

bcryptargon2jsonwebtokencrypto

HTTP

axiosnode-fetchwsnodemailer

Data Processing

cheeriosharpzliblodash

Date & Time

dayjsmomentdate-fnsnode-cron

Utilities

uuidnanoidslugifyvalidatordotenvrate-limiter-flexible
Just import and use - Perry automatically uses the native implementation

How It Works

From TypeScript source to native executable in seconds

TypeScript.ts files
SWC
ParserFast parsing
HIR
TransformMonomorphization
Crane
lift
CodegenMachine code
Executable2-5 MB binary

01NaN-Boxing

Values are stored as 64-bit floats with special bit patterns for pointers, enabling union types without runtime overhead. This allows (string | number)[] to work efficiently.

02Monomorphization

Generics are specialized at compile time, like Rust. Each type instantiation generates optimized code, eliminating runtime type checking overhead.

03Static Dispatch

No virtual tables. Method calls are resolved at compile time, enabling direct function calls and inlining optimizations.

04Zero-Cost Abstractions

TypeScript classes, interfaces, and generics compile to efficient native code with no runtime representation overhead.