liveBook · Manning

Ahead-of-time compilation

As explained in Modern Angular

Ahead-of-time compilation is compilation performed before an application is deployed or executed.

Ahead-of-time compilation compiles an Angular application before deployment or execution. The production build transforms templates into precompiled commands that the browser can execute directly, avoiding template compilation at runtime. section 9.2.3

Angular uses different compilation strategies for development and deployment:

  • Runs just-in-time compilation with ng serve, making development builds faster while shifting template compilation into the browser. section 9.2.3
  • Runs ahead-of-time compilation with ng build, producing a precompiled application for production execution. section 9.2.3
  • Supports server-side rendering because Angular-generated template commands are verified as platform-agnostic and can run on the server and browser. section 9.2.3

Production deployment

After development with ng serve, run ng build to obtain a precompiled application. The deployed browser receives compiled rendering commands rather than compiling Angular templates during execution. section 9.2.3

How Modern Angular covers it

How deep it goes
Contrasts development and production compilation, then connects precompiled templates to browser execution and server-side rendering.
Examples
Uses ng serve for development and ng build for a precompiled production application.
What it assumes
Assumes an Angular application with templates and familiarity with ng serve and ng build.
What you can do after
Apply it via Angular CLI by building a precompiled application for production deployment and server-side rendering.
How it connects
Connects just-in-time compilation, Angular templates, and server-side rendering through shared template compilation.

Also explained in

Compare how 3 books explain ahead-of-time compilation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern Angular. The section links point to the parts of the book it draws on.