{ "id": "guide/ivy", "title": "Angular Ivy", "contents": "\n\n\n
Ivy is the code name for Angular's next-generation compilation and rendering pipeline.\nWith the version 9 release of Angular, the new compiler and runtime instructions are used by default instead of the older compiler and runtime, known as View Engine.
\n\n\nAOT compilation with Ivy is faster and should be used by default.\nIn the angular.json workspace configuration file, set the default build options for your project to always use AOT compilation.\nWhen using application internationalization (i18n) with Ivy, translation merging also requires the use of AOT compilation.
Ivy applications can be built with libraries that were created with the View Engine compiler.\nThis compatibility is provided by a tool known as the Angular compatibility compiler (ngcc).\nCLI commands run ngcc as needed when performing an Angular build.
For more information on how to publish libraries see Publishing your Library.
\n\nIf you are a library author, you should keep using the View Engine compiler as of version 9.\nBy having all libraries continue to use View Engine, you will maintain compatibility with default v9 applications that use Ivy, as well as with applications that have opted to continue using View Engine.
\nSee the Creating Libraries guide for more on how to compile or bundle your Angular library.\nWhen you use the tools integrated into the Angular CLI or ng-packagr, your library will always be built the right way automatically.
In version 9, the server builder which is used for App shell and Angular Universal has the bundleDependencies option enabled by default.\nIf you opt-out of bundling dependencies you will need to run the standalone Angular compatibility compiler (ngcc). This is needed because otherwise Node will be unable to resolve the Ivy version of the packages.
You can run ngcc after each installation of node_modules by adding a postinstall npm script:
The postinstall script will run on every installation of node_modules, including those performed by ng update and ng add.
Don't use --create-ivy-entry-points as this will cause Node not to resolve the Ivy version of the packages correctly.
In version 9, Ivy is the default.\nFor compatibility with current workflows during the update process, you can choose to opt out of Ivy and continue using the previous compiler, View Engine.
\nBefore disabling Ivy, check out the debugging recommendations in the Ivy Compatibility Guide.
\nTo opt out of Ivy, change the angularCompilerOptions in your project's TypeScript configuration, most commonly located at tsconfig.app.json at the root of the workspace.
The value of the enableIvy flag is set to true by default, as of version 9.
The following example shows how to set the enableIvy option to false in order to opt out of Ivy.
If you disable Ivy, you might also want to reconsider whether to make AOT compilation the default for your application development, as described above.
\nTo revert the compiler default, set the build option aot: false in the angular.json configuration file.
If you disable Ivy and the project uses internationalization, you can also remove the @angular/localize runtime component from the project's polyfills file located be default at src/polyfills.ts.
To remove, delete the import '@angular/localize/init'; line from the polyfills file.
If you opt out of Ivy and your application uses Angular Universal to render Angular applications on the server, you must also change the way the server performs bootstrapping.
\nThe following example shows how you modify the server.ts file to provide the AppServerModuleNgFactory as the bootstrap module.
AppServerModuleNgFactory from the app.server.module.ngfactory virtual file.bootstrap: AppServerModuleNgFactory in the ngExpressEngine call.