A native Rust replacement for ng build in Angular projects. Drop-in swap, ~10× faster on real-world apps.
| Project | ngc-rs |
ng build |
Speedup |
|---|---|---|---|
| Production Angular v21 app (~1,200 modules, 14 lazy chunks) | ~380 ms | ~3,800 ms | ~10× |
Measured with hyperfine on Apple Silicon, -c production (source maps, minification, tree shaking, content-hashed filenames).
Status: v0.7.18 — parallel build pipeline ngc-rs reads
angular.json, compiles templates to Ivy, bundles with code splitting, and emits production-ready output with source maps, minified code, tree-shaken exports, and content-hashed filenames. Every hot stage — project resolution, template compilation, TS transform, npm dependency crawl, Angular linker, tree-shaking, bundling, and minification — runs across rayon worker threads. See the milestones for the roadmap toward a fullng buildreplacement.
The Angular CLI build pipeline runs on Node.js and is largely single-threaded. ngc-rs replaces it with a Rust binary that is multi-threaded end-to-end:
- oxc for native JS/TS parsing, codegen, and minification
- rayon for parallel per-file work at every stage
- petgraph for the file dependency graph
- dashmap for a shared
canonicalize()cache across worker threads — collapses duplicate filesystemstatsyscalls
Additional wins on the critical path:
- PostCSS/Tailwind subprocess overlaps with bundling rather than running after it — ~200 ms of wallclock absorbed
- Per-chunk bundling, minification, and tree-shake all fan out to worker threads
- npm dependency BFS resolves each frontier level in parallel
- Linker (
ɵɵngDeclare*→ɵɵdefine*for partially-compiled npm packages) processes all three of its passes in parallel
Type-checking is delegated to tsc --noEmit as a subprocess — we don't reimplement the TypeScript type system.
cargo install --git https://github.com/lukekania/ngc-rsOr build from source:
git clone https://github.com/lukekania/ngc-rs.git
cd ngc-rs
cargo build --releaseThe binary will be at target/release/ngc-rs.
Resolve the project file graph and print a summary:
ngc-rs info --project tsconfig.jsonngc-rs project info
Files: 1247
Entry points: 3
Edges: 4891
Unresolved: 12
Compile templates, transform TypeScript, and produce browser-ready output:
ngc-rs build --project tsconfig.app.jsonWhen an angular.json is found, ngc-rs reads styles, assets, polyfills, and file replacements from it automatically. Output includes:
dist/main.{hash}.js— ESM bundle with Ivy-compiled templates (content-hashed in production)dist/chunk-*.{hash}.js— lazy-loaded route chunksdist/main.{hash}.js.map— source maps (production: external files, development: inline)dist/index.html— with injected script/style tagsdist/styles.css— concatenated global stylesheetsdist/polyfills.js— polyfill importsdist/assets/— copied static assetsdist/3rdpartylicenses.txt— third-party license texts
Additional flags:
# Production build (minification, source maps, content hashes, npm bundling)
ngc-rs build --project tsconfig.app.json -c production
# Development build (no optimizations, fast iteration)
ngc-rs build --project tsconfig.app.json
# Machine-readable JSON output
ngc-rs build --project tsconfig.app.json --output-jsonReproduce the headline number against ng build with hyperfine:
cargo build --release
hyperfine --warmup 3 \
"./target/release/ngc-rs build --project /path/to/tsconfig.app.json --out-dir /tmp/ngc-rs-out -c production" \
"npx ng build --configuration production"Run the ng build invocation from inside the Angular project directory, or pass a cwd flag. Both commands include full production optimizations.
# Run tests
cargo test --workspace
# Lint
cargo clippy --workspace --all-targets -- -D warnings
# Format
cargo fmt --all
# All checks (CI runs this)
cargo test --workspace && cargo clippy --workspace --all-targets -- -D warnings && cargo fmt --checkSee the GitHub milestones for the full plan:
- v0.1 — Project Resolver ✅
- v0.2 — TS Transform ✅ (strip types with oxc, emit plain JS)
- v0.3 — Bundling ✅ (ESM concatenation with dependency ordering)
- v0.4 — Angular Template Compiler ✅ (Ivy codegen, pest parser)
- v0.5 — Build Output Completeness ✅ (angular.json, index.html, styles, assets, polyfills, fileReplacements)
- v0.6 — Code Splitting & Lazy Routes ✅ (dynamic import detection, chunk graph, multi-file output)
- v0.7 — Source Maps & Optimization ✅ (source maps, minification, content hashing, npm bundling)
- v0.7.x — Angular 21 & Performance ✅ (full-pipeline rayon parallelism, overlapped PostCSS, canonicalize cache — 4.2× → ~10× vs
ng build) - v0.8 — Watch Mode & Dev Server
- v1.0 — Angular CLI Drop-in (swap one line in
angular.json). Angular linker for partially-compiled npm packages already landed.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.