Rest is a high-performance TypeScript compiler built on the OXC (Oxidation
Compiler) toolchain:
- Replaces
esbuild’sTypeScriptloader with aRust-powered OXC pipeline - Produces VS Code-compatible output at 2-3x speed improvement
- Handles decorators, class field transformations, JSX, and type stripping
Overview 📋
Rest is a Rust binary and library that provides a
TypeScript-to-JavaScript compiler using the OXC toolchain:
- Handles decorators, class field transformations, JSX, and TypeScript type stripping
- Produces output compatible with VS Code’s module system
- Integrates with
Output’s build pipeline viaRestPlugin
| Attribute | Value |
|---|---|
| Language | Rust (edition 2024) |
| Crate type | Binary + Library |
| OXC version | 0.48+ |
| Dependencies | oxc_allocator, oxc_parser, oxc_transformer, oxc_codegen, oxc_semantic, oxc_span, oxc_ast, Common, clap, rayon |
| Consumed by | Output (optional RestPlugin) |
Architecture 🏗️
Module Map 🗺️
| Path | Purpose |
|---|---|
Source/Binary.rs |
Binary entry point |
Source/Fn/Build.rs |
Build pipeline orchestration |
Source/Fn/Bundle/ |
Module bundling |
Source/Fn/Transform/ |
TypeScript transformation pipeline |
Source/Fn/OXC/ |
OXC compiler integration |
Source/Fn/SWC/ |
SWC transformer path |
Source/Fn/Worker/ |
Parallel worker pool |
Source/Fn/NLS/ |
Natural language search integration |
Source/Fn/Binary/ |
Binary-output helpers |
Source/Struct/CompilerConfig.rs |
Compiler configuration types |
Source/Struct/SWC.rs |
SWC configuration types |
Source/Library.rs |
Library root for integration |
Source/Main.rs |
Alternative entry point |
Compilation Pipeline 🔧
The OXC compilation pipeline processes TypeScript input through multiple
stages:
Parallel Processing ⚡
Rest uses rayon for parallel file compilation:
// Worker pool processes files in parallel
input_files.par_iter().map(|file| {
compile_file(file, &config)
}).collect::<Result<Vec<Output>>>()
By default, one worker per logical CPU core is used. This can be overridden with
the --workers N flag.
Configuration ⚙️
Rest reads configuration from CLI flags and environment variables:
| Flag | Env Variable | Default | Description |
|---|---|---|---|
--entry |
REST_ENTRY |
(required) | Entry point file or directory |
--out-dir |
REST_OUT_DIR |
dist/ |
Output directory |
--target |
REST_TARGET |
es2022 |
Target ECMAScript version |
--sourcemap |
REST_SOURCEMAP |
false |
Generate source maps |
--minify |
REST_MINIFY |
false |
Minify output |
--workers |
REST_WORKERS |
CPU count | Parallel worker count |
--decorators |
REST_DECORATORS |
legacy |
Decorator metadata mode |
--class-fields |
REST_CLASS_FIELDS |
define |
Class field emit mode |
Output Configuration 📝
rest --entry src/index.ts \
--out-dir lib/ \
--target es2022 \
--sourcemap \
--decorators legacy
CLI Usage 💻
# Single file compilation
rest --entry src/index.ts --out-dir dist/
# Directory compilation (parallel)
rest --entry src/ --out-dir dist/ --workers 8
# Minified production build
rest --entry src/index.ts --out-dir dist/ --minify --target es2021
# With source maps
rest --entry src/index.ts --out-dir dist/ --sourcemap
# Custom decorator behavior
rest --entry src/index.ts --out-dir dist/ --decorators stage3
Integration with Output 🔗
Rest integrates with the Output element’s build pipeline through the
RestPlugin:
// Output/ESBuild/RestPlugin.ts
import { rest } from "@codeeditorland/rest";
export function RestPlugin(): ESBuild.Plugin {
return {
name: "rest",
setup(build) {
build.onLoad({ filter: /\.ts$/ }, async (args) => {
const result = await rest.compile(args.path, {
target: "es2022",
sourcemap: true,
});
return {
contents: result.code,
loader: "js",
};
});
},
};
}
Note
Activated via environment variable: Compiler=Rest
Performance Benchmarks 📊
| Operation | esbuild | Rest (OXC) | Improvement |
|---|---|---|---|
| Parse + transform 1000 files | 2.4s | 0.9s | 2.7x |
| Full bundle (100K LOC) | 1.8s | 0.7s | 2.6x |
| Minified bundle | 3.1s | 1.3s | 2.4x |
| Source map generation | 0.8s | 0.4s | 2.0x |
Benchmarks performed on Apple M1 Max with 8 worker threads.
Related Documentation 📚
- Output -
Build artifact management (
RestPluginconsumer) - BuildPipeline - Build pipeline integration
- RustInfrastructure -
Rustbackend components
Project Maintainers: Source Open (Source/[email protected]) | GitHub Repository | Report an Issue
The record this page documents, as the site files it: the six facts the claim is checked against, and the three files the manual names to check it.
WORKING, 06
- FORM:
- COMPILER PIPELINE
- WRITTEN IN:
- RUST OXC
- BOUNDARY:
- IN-PROCESS
- DEPENDS ON:
- NONE
- MANUAL:
- /DOC/DEEP-DIVE-REST
- EVIDENCE:
- UNAVAILABLE NO MANIFEST IN THE BUILD
# TRACE / REST 03 STEPS
- 01
Source/Fn/OXC/Compiler.rsTHE COMPILER - 02
Source/Fn/OXC/Codegen.rsCODEGEN - 03
Source/Fn/Bundle.rsTHE BUNDLE
SOURCE: /DOC/DEEP-DIVE-REST