Urgent.News

What's breaking now, across thousands of outlets.

Tech

Angular's TypeScript 7-Powered Compiler Enters Beta with Rust-Based Preprocessor

The Angular team has introduced ngp, a compiler preprocessor that rewrites the analysis stage in Rust using Oxc. It replaces ngc's dependence on the Transformer API, which TypeScript 7.0 removed. An early benchmark showed 2x to 3x faster cold builds. Adoption is expected in an Angular 22 minor release; production builds should stay on ngc until then. By Daniel Curtis

The Angular team has introduced a new version of its compiler, the Angular Preprocessor (ngp), which undergoes a rewrite of the analysis stage using Rust technology. This development came shortly after Microsoft released TypeScript 7.0, which replaced the ts.Transformer API relied upon by Angular's ahead-of-time compiler. The existing compiler, ngc, utilizes the Transformer API to convert decorators like @Component and @Pipe into runtime instructions.

To address this, the Angular team decided to decouple compilation from TypeScript's APIs and rebuild it on Oxc, the VoidZero Rust toolchain, which is already used by Vite. The ngp operates in three stages: a Rust frontend powered by Oxc analyzes files concurrently to identify Angular declarations and resolve metadata. The TypeScript template compiler then generates two artifacts - a runtime file with the transformed component and a .ngtypecheck.ts file containing the Type Check Block (TCB) for template type-checking.

Finally, a downstream tool like tsgo, tsrs, esbuild, or Rollup handles type-checking and JavaScript emission independently.

The beta release of ngp was made available on October 8th, with Cédric Exbrayat from Ninja Squad comparing its performance against three projects with varying numbers of components. The results showed a 2x to 3x speedup on cold builds, and a reduction in memory usage for the largest project from 2.8 GB to 1.4 GB. Pairing ngp with tsrs and Rollup proved to be the fastest pipeline, while tsgo and esbuild were only slightly slower. Further performance improvements are expected as the team focuses on optimizing the technology.

Christopher Holder at push-based.io created vite-plugin-ngp to compile Angular files on demand, which significantly improved the dev server's performance on a codebase with 252 components. However, it is currently a prototype and not yet stable. On Reddit, many developers praised the update, expressing their excitement about the potential improvements.

VoidZero's experimental Oxc Angular compiler, which showed a roughly 97% improvement on narrower workloads, has been described as actively seeking maintainers. The Angular team confirmed that VoidZero's work influenced the architecture of ngp and that the two groups have been collaborating, with ngp becoming the official path moving forward.

Written by urgent.news from InfoQ's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at infoq.com →

More in Tech

LG Launches Smartphone App to Manage ePaper Displays

LG Electronics has launched a dedicated smartphone app for its ultra-low-power commercial display, the LG E-Paper Display, allowing users to manage screen content and monitor device status directly…

  • LG launches smartphone app for E-Paper Display
  • App enables content control via Bluetooth
  • Power Management optimizes energy efficiency

More from Wednesday 11 November →