Angular 9.0: The Ivy Compiler, Bundle Size Reductions, and Compilation Speeds

Production-ready Ivy. We explore the Ivy compiler, compile-time type checks, and bundle optimization.

VP
SHIVAM ITCS
·8 April 2020·10 min read·1 views

Technical Overview & Strategic Context

While early Angular versions supported building single-page applications, compile times and bundle sizes remained a challenge for large enterprise codebases. The release of Angular 9.0 in early 2020 resolved this by making the Ivy compiler and renderer active by default, reducing bundle sizes, improving compilation speeds, and standardizing compile-time type checking.

Architectural Principle: Migrate Angular codebases to the Ivy compiler engine. Enforce strict compile-time type checks to identify template errors early in builds.

Core Concepts & Architectural Blueprint

The Ivy compiler changes how Angular components are compiled: it translates templates into simple, tree-shakeable JavaScript code, reducing bundle sizes for small and large applications. Ivy also updates compile-time type checking, verifying template variable types against TypeScript schemas, catching errors during compilation.

Performance & Capability Comparison

Compiler LayerViewEngine (Pre-Angular 9)Ivy Compiler default (9.0)Operational Benefit
Bundle SizeLarger (contains framework runtime overhead)Surgical, tree-shakeable componentsReduces bundle sizes by up to 40%
Template TypesBasic parsing validationStrict template type checking contextCatches template binding errors early
DebuggingOpaque stack tracesClear, trace-friendly execution stacksSimplifies component debugging

Implementation & Code Pattern

To configure an Angular 9.0 workspace for Ivy compilation, developers should follow these steps:

  • Ensure TypeScript configurations inside tsconfig.json enable strict template checks.
  • Compile applications using the prod flag to verify Ivy optimization outputs.
  • Check that libraries are compiled in compatibility mode before deployment.
  • Verify bundle sizes using angular-cli bundle visualizers.
jsoncode
// tsconfig.json configurations for Angular 9.0 Ivy strict checks
{
  "compilerOptions": {
    "target": "es2015",
    "module": "esnext",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "noImplicitAny": true
  },
  "angularCompilerOptions": {
    // Enable strict template type checking context in Ivy
    "strictTemplates": true,
    "enableIvy": true
  }
}

Operational Governance & Future Outlook

Angular 9.0's Ivy compiler simplified project builds and optimized bundle sizes. Enforcing strict template type checking helps teams find bugs early, improving frontend reliability.

VP
Vijay Paliwal
Founder, SHIVAM ITCS · 18+ years enterprise & AI engineering
MCA · Ex-HiveGPT USA · Ex-Social27 Seattle
Angular 9.0: The Ivy Compiler, Bundle Size Reductions, and Compilation Speeds | SHIVAM ITCS Blog | SHIVAM ITCS