Using AOT Compilation in Angular to reduce build size

Опубликовано: 25 Февраль 2026
на канале: ChariotSolutions
8,083
37

Developers who have been using angular-cli for a while now know the ease that they can fire up and test their project with ng serve. But it turns out that the Angular team updated the recent @angular/cli (the replacement NPM module for angular-cli) to support ahead-of-time compilation of JavaScript targets.

This means that you can have savings of 30% or more on the final output size of your libraries. For example, in our tutorial here we are able to shave off several megabytes from the size of the vendor JavaScript library and bring the size in under 800k. The RxJS library compresses from over 700k to under 300k.

This short tutorial shows you how to proceed, but you must follow rules for your code, such as not exporting functions or methods that depend on late-bound types. See https://github.com/UltimateAngular/ao... and   / making-your-angular-2-library-statically-a...   for more details.

Want training in Angular for your team? We'll come to you. Register for our 3-day Angular Workshop (chariotsolutions.com/ngtraining).