Angular Blog | Medium
Follow
An update on Angular’s TypeScript 7-powered Compiler
Angular's development team is introducing a new compiler, "ngp," to improve performance and leverage native tooling. For years, Angular has relied heavily on TypeScript, which has been instrumental in scaling the framework. However, a Go-compiled version of TypeScript, like TypeScript 7, is incompatible with Angular's deeply integrated compiler. To address this, Angular is decoupling its compilation process from TypeScript's compiler APIs. They are building a new, Angular-specific compiler that will process components and templates. This new compiler will output transformed TypeScript code ready for the build pipeline. Many frameworks are now separating code generation from type-checking and often use the oxc library. Oxc, written in Rust, is a native toolchain for JavaScript parsing and compilation powering tools like Vite. The new Angular Preprocessor, ngp, aims to achieve similar performance benefits to native tooling. Ngp has two primary tasks: compiling Angular decorators and facilitating template expression type-checking. It generates two output files per source file: one for compiled code and another for type-checking. Currently, ngp is a hybrid architecture, using Rust for its frontend and TypeScript for its backend. The Rust frontend, built with oxc, parses code and identifies Angular constructs. The TypeScript backend executes compilation tasks and generates output. Ngp is nearing its Minimum Viable Product stage, with experimental versions planned for release later this year. While early testing is encouraging, definitive performance comparisons will only be possible after benchmarking the full build process. The new compiler is also being prototyped to power the Angular language service. There may be minor breaking changes related to type-checking behavior. The team chose Rust and oxc over Go due to the availability of a robust JavaScript/TypeScript toolchain library.