Angular 8 - Ivy Compiler



Ivy Compiler is the latest compiler for Angular application released by Angular Team. Currently, Angular is using View Engine compiler to compile Angular application.

In general, Angular compiler has two options to compile an application.

Just In Time (JIT) Compiler

In Just In Time (JIT) compilation, the compiler will be bundled along with the application and send to the browser. Angular application will be compiled in the browser and run just before the execution of application.

Eventhough JIT provides certain advanced feature, JIT slows down the compilation and also the app bundle will be double the size produced by AOT compiler as it includes compiler as well.

Ahead Of Time (AOT) Compiler

In AOT compilation, the compiler will emit optimised code ready to run inside the browser without any addition step. It will reduce the size of the bundle as well as reduce the compilation time and startup time of the application.

Advantages of Ivy Compiler

Ivy Compiler is the optimised and advanced compiler for Angular. As of Angular 8, it is not yet complete even though it is useable at this stage. Angular Team is recommending the developer to use it in Angular 8.

The main advantages of Ivy Compiler are as follows −

  • Optimised code.
  • Faster build time.
  • Reduced bundle size.
  • Better performance.

How to use Ivy?

Ivy Compiler can be used in Angular 8 application by changing the project setting as specified below −

Open angular.json and set the aot option (projects -> -> architect -> build -> configurations -> production) of the project to true.

{
   "projects": {
      "my-existing-project": {
         "architect": {

            "build": {
               "options": {
                  ...
                  "aot": true,
               }
            }
         }
      }
   }
}

Open tsconfig.app.json and set enableIvy to true under angularCompilerOptions.

{ 
   ... 
   "angularCompilerOptions": { 
      "enableIvy": true 
}

Compile and run the application and get benefited by Ivy Compiler.

Advertisements