Warning
This project is in an experimental stage and is actively seeking maintainers.
A high-performance Angular template compiler written in Rust, leveraging the Oxc infrastructure for blazing-fast compilation.
- Rust-Powered Performance - Native compilation via NAPI-RS for maximum speed
- Vite Integration - First-class Vite plugin with full HMR support
- Drop-in Compatible - API compatible with
@angular/compiler-cli - Full Angular Support - Components, directives, pipes, injectables, and NgModules
- Hot Module Replacement - Fast refresh for templates and styles during development
- Style Encapsulation - ViewEncapsulation.Emulated, None, and ShadowDom support
- i18n Ready - Message extraction with XLIFF 1.2/2.0, XMB, and XTB formats
- Build Optimizations - Constant folding, pure function extraction, unused code removal
npm install @oxc-angular/vite
# or
pnpm add @oxc-angular/vite
# or
yarn add @oxc-angular/vite// vite.config.tsimport{defineConfig}from'vite'import{angular}from'@oxc-angular/vite'exportdefaultdefineConfig({plugins: [angular({// Optional configurationangularVersion: {major: 21,minor: 0,patch: 0},liveReload: true,}),],})import{compileTemplate,transformAngularFile}from'@oxc-angular/vite/api'// Compile a template stringconstresult=awaitcompileTemplate('<div>{{ message }}</div>','AppComponent','app.component.ts',{angularVersion: {major: 21,minor: 0,patch: 0},hmr: false,},)console.log(result.code)// Transform an entire Angular fileconsttransformed=awaittransformAngularFile(` import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: '<h1>Hello {{ name }}</h1>', }) export class AppComponent { name = 'World'; } `,'app.component.ts',)console.log(transformed.code)Compiles an Angular template string to JavaScript.
| Parameter | Type | Description |
|---|---|---|
template | string | The HTML template string |
componentName | string | Name of the component class |
filePath | string | Path to the component file |
options | TransformOptions | Optional compilation options |
Returns: Promise<TemplateCompileResult>
Transforms an Angular TypeScript file, compiling any component templates.
| Parameter | Type | Description |
|---|---|---|
source | string | The TypeScript source code |
filename | string | Path to the source file |
options | TransformOptions | Optional compilation options |
Returns: Promise<TransformResult>
interfaceTransformOptions{// Angular version (19, 20, 21)angularVersion?: {major: numberminor: numberpatch: number}// Enable Hot Module Replacementhmr?: boolean// Enable cross-file type elisionenableCrossFileElision?: boolean// i18n configurationi18nNormalizeLineEndingsInIcus?: booleani18nUseExternalIds?: boolean// Style encapsulation mode// 'emulated' | 'none' | 'shadow-dom'encapsulation?: string}The compiler implements a 6-stage pipeline:
HTML Template
↓
PARSING → HTML AST
↓
TRANSFORM → R3 AST (Angular's internal representation)
↓
INGESTION → Intermediate Representation (IR)
↓
TRANSFORMATION → 67 optimization phases
↓
EMISSION → Output AST
↓
CODE GENERATION → JavaScript
| Module | Purpose |
|---|---|
parser | HTML and expression parsing |
transform | HTML to R3 AST transformation |
ir | Intermediate Representation operations |
pipeline | 67 transformation phases |
output | JavaScript code generation |
hmr | Hot Module Replacement support |
styles | CSS processing and encapsulation |
i18n | Internationalization support |
Pre-built binaries are available for:
| Platform | Architecture |
|---|---|
| macOS | Apple Silicon (aarch64), Intel (x86_64) |
| Windows | x86_64, aarch64 |
| Linux | x86_64 (glibc, musl), aarch64 (glibc, musl) |
- Node.js 20.19.0+ or 22.12.0+
- Vite 6.0.0+ (for Vite plugin)
- Rust 1.90.0+
- Node.js 20.19.0+
- pnpm
# Clone the repository
git clone https://github.com/voidzero-dev/oxc-angular-compiler.git
cd oxc-angular-compiler
# Install dependencies
pnpm install
# Initialize submodules
git submodule update --init
# Build NAPI bindings
pnpm build
# Run tests
pnpm test# Build (development)
pnpm build-dev
# Run Rust tests
cargo test# Run Node.js tests
pnpm test# Run E2E tests
pnpm test:e2e
# Run conformance tests against Angular
cargo run -p oxc_angular_conformance
# Start playground
pnpm playgroundoxc-angular-compiler/
├── crates/
│ ├── oxc_angular_compiler/ # Core Rust compiler
│ └── angular_conformance/ # Conformance testing
├── napi/
│ └── angular-compiler/
│ ├── src/ # NAPI bindings
│ ├── vite-plugin/ # Vite plugin (TypeScript)
│ ├── e2e/ # E2E tests
│ └── test/ # Integration tests
└── Cargo.toml # Rust workspace
Measured on Apple M3 Max (16 cores, 128 GB RAM), Node.js 22.22.0, 3 iterations averaged.
| Builder | Average | Speedup |
|---|---|---|
| Vite + OXC Angular Compiler | 4.55s | 20.7x |
Webpack + @ngtools/webpack | 1m 34.2s | baseline |
cd napi/angular-compiler/benchmarks/bitwarden
# Install dependencies
pnpm install
# Run full benchmark (cold + incremental, 3 iterations)
pnpm benchmark
# Cold build only
pnpm benchmark --cold
# Vite/OXC only (no baseline comparison)
pnpm benchmark --vite-only
# Custom iteration count
pnpm benchmark --iterations=5See napi/angular-compiler/benchmarks/ for additional benchmark targets.
Contributions are welcome! Please read the contributing guidelines before submitting pull requests.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request