Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 8 with Ivy how to verify it is used

Tags:

angular

Today I installed Angular 8 final version.

npm install -g @angular/cli

Generated a simple app with:

ng new sampleApp

On https://angular.io/guide/ivy site I found that I have to modify tsconfig.app.json file to enable Ivy. Like this:

"angularCompilerOptions": {
    "enableIvy": true
}

My question is after I perform build how can I verify that Ivy is in place and used as a rendering engine?

like image 643
robert Avatar asked May 29 '19 20:05

robert


People also ask

How do you use Ivy in Angular 8?

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 . AOT compilation with Ivy is faster and should be used by default.

Is Angular Ivy enabled by default?

The value of the enable Ivy flag is set to true by default, as of version 9. The following example shows how to set the enable Ivy option to false in order to opt-out of Ivy. If you disable Ivy, you might also want to reconsider whether to make the AOT compilation the default for your application development.

In which version of Angular Ivy compiler is enabled by default?

In version 9, Ivy is the default. For compatibility with current workflows during the update process, you can choose to opt out of Ivy and continue using the previous compiler, View Engine.

What is the benefit of Ivy Angular?

Ivy is much more efficient than ViewEngine. For each component in Angular less code is generated since the compiler removes the unused parts of Angular. This has a huge impact on the size of the app. The difference in bundle size between Angular 8 apps and Angular 9 apps is almost 40%.


2 Answers

New rendering engine prefers adding expando properties to many objects rather than new wrapping type.

You can open your application in chrome browser and check if any of elements inside your Angular application has __ngContext__ property.

enter image description here

https://ivy.ng-run.com/

like image 98
yurzui Avatar answered Oct 06 '22 12:10

yurzui


When you set enableIvy to true

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

then ngcc command is executed by running ng serve or ng build. You can recognize it in the console easily because it will start printing out something like this

Compiling @angular/core : es2015 as esm2015

Compiling @angular/common : es2015 as esm2015

Compiling @angular/platform-browser : es2015 as esm2015

...

The seconds possible way is by checking bundle size as it was mentioned in comments.

Also there is a short paragraph about Ivy and Bazel on Angular blog that we will get more info about Ivy next week.

We know there’s lots of excitement for our forthcoming opt-in previews. We’ll be providing individual updates on these next week on this blog, so stay tuned!

like image 34
Josef Katič Avatar answered Oct 06 '22 11:10

Josef Katič