Skip to main content

Deep Dive

Rest - Deep Dive

Rest TypeScript compiler architecture, OXC toolchain pipeline, key modules, data flow, integration points with Output/Cocoon/Sky, and configuration reference.

Rest provides the technical foundation TypeScript compiler within the Land project. Rest is a Rust binary that uses the OXC toolchain to compile TypeScript 2-3x faster than esbuild while producing output compatible with VS Code’s build process.


Architecture

Rest is structured as a Rust library with a binary entry point. The compilation pipeline passes source files through OXC’s parser, transformer, and code generator in sequence. An optional parallel mode processes multiple files concurrently across CPU cores.

Mermaid diagram ---

Key Modules

PathDescription
Source/Library.rsBinary entry point; parses CLI arguments and dispatches to compiler
Source/Fn/OXC/Compiler.rsMain compilation orchestrator; coordinates parser, transformer, and codegen
Source/Fn/OXC/Parser.rsWraps oxc_parser with error normalization and source tracking
Source/Fn/OXC/Transformer.rsApplies TypeScript-to-JavaScript AST transformations including decorators
Source/Fn/OXC/Codegen.rsGenerates final JavaScript text from the transformed AST
Source/Fn/Build.rsDirectory-based compilation: walks source trees preserving structure
Source/Fn/Bundle/Bundling utilities for multi-file outputs
Source/Fn/NLS/Natural Language Support string extraction
Source/Fn/SWC/SWC integration shims (alternative transformer path)
Source/Fn/Worker/Worker thread support for parallel compilation
Source/Struct/CompilerConfig.rsConfiguration struct: decorator mode, class fields, source maps
Source/Struct/SWC.rsSWC-specific configuration types

Data Flow

Mermaid diagram When `--Parallel` is specified, the compiler fans out file compilation across Tokio worker threads and collects aggregated metrics.

Integration Points

Connecting ElementDirectionMechanismDescription
OutputConsumerProcess invocation / esbuild pluginOutput’s RestPlugin.ts invokes the Rest binary or calls it via plugin API
CocoonIndirect consumerCompiled artifactsCocoon loads the JavaScript produced by Rest from Target/Microsoft/VSCode/
SkyIndirect consumer@codeeditorland/output packageSky loads VS Code UI components compiled through the Rest pipeline

Configuration

OptionCLI Flag / VariableDefaultDescription
Input path--InputrequiredDirectory or file to compile
Output path--OutputrequiredDestination directory for compiled JavaScript
Parallel mode--ParalleloffEnable multi-core parallel compilation
Decorator metadataCompilerConfigtrueEmit emitDecoratorMetadata for VS Code compatibility
Class fields modeCompilerConfigfalse (VS Code default)useDefineForClassFields - off matches VS Code’s gulp build
Source mapsCompilerConfigdevelopment onlyInline source maps for debug builds

The CompilerConfig struct is populated from either CLI flags or from the esbuild plugin context when Rest is invoked as a plugin within the Output build pipeline.