Skip to main content

Deep Dive

Rest - Deep Dive

OXC-based TypeScript compiler with parallel execution and VSCode compatibility

Rest - Deep Dive

Rest is a Rust binary that uses the OXC toolchain to compile TypeScript 2-3x faster than esbuild while producing output compatible with VSCode’s build process.

Architecture 🏗️

Compilation pipeline: source files pass through OXC parser, transformer, and code generator in sequence. Optional parallel mode processes multiple files concurrently.

Modules

Path
Source/Library.rs - Binary entry point, CLI parsing, compiler dispatch
Source/Fn/OXC/Compiler.rs - Main orchestration: parser, transformer, codegen
Source/Fn/OXC/Parser.rs - Wraps oxc_parser with error normalization
Source/Fn/OXC/Transformer.rs - TypeScript-to-JavaScript AST transformations
Source/Fn/OXC/Codegen.rs - JavaScript generation from transformed AST
Source/Fn/Build.rs - Directory-based compilation preserving structure
Source/Fn/Bundle/ - Bundling utilities
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.rs - Configuration: decorators, class fields, source maps

Compilation Flow 🔄

CLI / RestPlugin -> Compiler
  -> Parser (OXC Parser) -> AST + diagnostics
  -> Transformer -> Transformed AST
  -> Codegen -> JavaScript text
  -> Write .js file to output directory

Transformer applies:

  • emitDecoratorMetadata (VSCode compatibility)
  • useDefineForClassFields=false (matches VSCode gulp build)
  • TypeScript type stripping

When --Parallel is specified, file compilation fans out across Tokio worker threads.

VSCode Compatibility Settings ⚙️

OptionValueDescription
Decorator metadatatrueRequired for VSCode dependency injection
Class fields modefalseMatches VSCode’s gulp build behavior
Source mapsdevelopment onlyInline maps for debug builds

Configuration ⚙️

CLI FlagDefaultDescription
--InputrequiredDirectory or file to compile
--OutputrequiredDestination for compiled JavaScript
--ParalleloffMulti-core parallel compilation

Integration 🔗

ElementDirectionMechanism
OutputConsumerProcess invocation / esbuild plugin
CocoonIndirectLoads JS from Target/Microsoft/VSCode/
SkyIndirectLoads VSCode UI components via Output package