How do I enable Ivy on a Angular 8 or 9 project?

Ivy is the upcoming render engine for Angular which introduces a lot of nice features without changing the current code base of Angular projects.

source and more information go though this

Reference : https://dzone.com/articles/how-to-upgrade-angular-packagesenable-ivy-compiler

you can auto upgrade

npm i -g @angular/cli@latestng update

or in your tsconfig.json file update this

{
  "compilerOptions": {
    "module": "esnext",
    // ...
  },
  "angularCompilerOptions": {
    "enableIvy": true,
    "allowEmptyCodegenFiles": true
  }
}

then your angular.json file

{
  "projects": {
    "your-project": {
      "architect": {
        "build": {
          "options": {
            ...
            "aot": true,
          }
        }
      }
    }
  }
}
26 users liked answer #0dislike answer #026
Chanaka Weerasinghe profile pic
Chanaka Weerasinghe

use this official guide.

Using Ivy in a new project :

To start a new project with Ivy enabled, use the --enable-ivy flag with the ng new command:

ng new shiny-ivy-app --enable-ivy

The new project is automatically configured for Ivy. Specifically, the enableIvy option is set to true in the project's tsconfig.app.json file.

Using Ivy in an existing project :

To update an existing project to use Ivy, set the enableIvy option in the angularCompilerOptions in your project's tsconfig.app.json.

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

AOT compilation with Ivy is faster and should be used by default. In the angular.json workspace configuration file, set the default build options for your project to always use AOT compilation.

{
  "projects": {
    "my-existing-project": {
      "architect": {
        "build": {
          "options": {
            ...
            "aot": true,
          }
        }
      }
    }
  }
}

To stop using the Ivy compiler, set enableIvy to false in tsconfig.app.json, or remove it completely. Also remove "aot": true from your default build options if you didn't have it there before.

17 users liked answer #1dislike answer #117
Stak profile pic
Stak

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).