<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Eugenio Lentini</title>
    <description>The latest articles on Forem by Eugenio Lentini (@eugeniolentini).</description>
    <link>https://forem.com/eugeniolentini</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F123409%2F8dc27b27-1999-4bf4-bcfd-963ada28af91.jpeg</url>
      <title>Forem: Eugenio Lentini</title>
      <link>https://forem.com/eugeniolentini</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/eugeniolentini"/>
    <language>en</language>
    <item>
      <title>An introduction to Angular 9 Ivy Compiler</title>
      <dc:creator>Eugenio Lentini</dc:creator>
      <pubDate>Sat, 14 Mar 2020 16:09:43 +0000</pubDate>
      <link>https://forem.com/eugeniolentini/an-introduction-to-angular-9-ivy-compiler-177n</link>
      <guid>https://forem.com/eugeniolentini/an-introduction-to-angular-9-ivy-compiler-177n</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Lingo&lt;/li&gt;
&lt;li&gt;Quick overview&lt;/li&gt;
&lt;li&gt;
Angular Ivy compiler model

&lt;ul&gt;
&lt;li&gt;Compiler enables decoupling&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Simple project setup

&lt;ul&gt;
&lt;li&gt;Let's compile&lt;/li&gt;
&lt;li&gt;JiT vs. AoT&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Compilation models

&lt;ul&gt;
&lt;li&gt;TypeScript compilation model&lt;/li&gt;
&lt;li&gt;Angular compilation model&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
TypeScript transpiler architecture

&lt;ul&gt;
&lt;li&gt;Extension points&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Compilation steps&lt;/li&gt;
&lt;li&gt;
Compiler features

&lt;ul&gt;
&lt;li&gt;Module compilation scope&lt;/li&gt;
&lt;li&gt;Export compilation scope&lt;/li&gt;
&lt;li&gt;Partial evaluation&lt;/li&gt;
&lt;li&gt;Template type checking&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Conclusions&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;&lt;br&gt;
The post contains the thoughts of a preliminary investigation on how Angular works reading some parts of the source code, debugging a simple application and reading how the compiler works. Some terms or definitions could be wrong.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why does Angular have a compiler at all?&lt;br&gt;
Main job of the compiler is to turn the template you write into the code that runs the Angular runtime.&lt;/p&gt;

&lt;p&gt;Alex Rickabaugh - Angular Connect 2019&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In Angular, the developer write templates &lt;em&gt;declaratively&lt;/em&gt; that is &lt;em&gt;what to render&lt;/em&gt;, the binding, etc. &lt;em&gt;but not how it happens at runtime&lt;/em&gt;, there is not description about how the change detection mechanism works. The Angular runtime does not understand the &lt;em&gt;declarative template syntax&lt;/em&gt; so it has to be translated into something the runtime can run into a browser.&lt;/p&gt;

&lt;p&gt;The compiler takes the &lt;em&gt;declarative Angular syntax&lt;/em&gt; and turns it into &lt;em&gt;imperative code&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Why, again, a compiler is required? not possible to do by hand?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lot of boilerplate code, better to focus on the business logic than how things work under the hood.&lt;/li&gt;
&lt;li&gt;Angular team can optimise and improve by release w.r.t. browser evolution the imperative code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A more detailed introduction about Angular Ivy can be found at&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/eugeniolentini" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qdSOHU2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--AzOlxhmz--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/123409/8dc27b27-1999-4bf4-bcfd-963ada28af91.jpeg" alt="eugeniolentini image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/eugeniolentini/angular-ivy-a-detailed-introduction-oj1" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Angular Ivy: a detailed introduction&lt;/h2&gt;
      &lt;h3&gt;Eugenio Lentini ・ Dec 10 '19 ・ 14 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#angular&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Lingo &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Angular Compiler:&lt;/em&gt; part of the Angular rendering architecture that transforms &lt;em&gt;templates&lt;/em&gt; and &lt;em&gt;decorators&lt;/em&gt; into something that the Angular runtime can understand.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Angular Runtime:&lt;/em&gt; part of the Angular rendering architecture that runs an Angular application.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Angular template declarative syntax:&lt;/em&gt; describes &lt;em&gt;what&lt;/em&gt; the view has to look like, &lt;em&gt;what&lt;/em&gt; the view has to display, but not &lt;em&gt;how&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Angular application imperative code:&lt;/em&gt; describes &lt;em&gt;how&lt;/em&gt; the view has to be rendered via a sequence of JavaScript instructions/commands.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Metadata:&lt;/em&gt; set of data enclosed into a decorator that describes the entity represented by the decorator itself. For instance a component has the selector, the template, etc. Metadata are then reused by the compiler and put into the definition files &lt;code&gt;.d.ts&lt;/code&gt;, the component API. Basically the metadata help to preserve the information removed from &lt;code&gt;.js&lt;/code&gt; files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick overview &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The work done on the new Angular compiler can be divided in three categories as stated in the &lt;a href="https://github.com/angular/angular/blob/master/packages/core/src/render3/STATUS.md"&gt;implementation status&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@angular/compiler-cli&lt;/code&gt;: TypeScript transformer pipeline which includes two CLI tools

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ngtsc&lt;/code&gt;: the Angular TypeScript compiler which looks for the &lt;a href="https://github.com/angular/angular/blob/master/packages/core/src/render3/STATUS.md#decorators"&gt;Angular decorators&lt;/a&gt; like &lt;code&gt;@Component&lt;/code&gt; and substitute them with their specific Angular Runtime instructions/counterparts like &lt;code&gt;ɵɵdefineComponent&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ngcc&lt;/code&gt;: the Angular Compatibility Compiler which converts pre-ivy modules into ivy-module, can be even run as part of a code loader like Webpack to have packages from &lt;code&gt;node_modules&lt;/code&gt; transpiled on-the-fly.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@angular/compiler&lt;/code&gt;: Ivy Compiler which converts decorators into Ivy.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@angular/core&lt;/code&gt;: decorators which can be converted by the &lt;code&gt;@angular/compiler&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Angular Ivy compiler model &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/angular/angular/blob/master/packages/compiler/design/architecture.md#the-ivy-compilation-model"&gt;Ivy model&lt;/a&gt; foresees to compile the Angular decorators like &lt;code&gt;@Injectable&lt;/code&gt;, &lt;code&gt;@Component&lt;/code&gt;, etc into &lt;em&gt;static properties&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;All the decorators do not need global knowledge of the application, except &lt;code&gt;@Component&lt;/code&gt; which requires information coming from &lt;code&gt;@NgModule&lt;/code&gt;. In the module other selectors used by the &lt;em&gt;component template&lt;/em&gt; are declared and so &lt;a href="https://github.com/angular/angular/blob/master/packages/compiler/design/architecture.md"&gt;the transitive closure of the exports of that module imports&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Without those information the &lt;em&gt;component def&lt;/em&gt; (&lt;code&gt;ɵcmp&lt;/code&gt;) cannot be correctly generated.&lt;/p&gt;

&lt;p&gt;Consider the &lt;code&gt;Welcome to Angular!&lt;/code&gt; application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;div style="text-align:center"&amp;gt;
      &amp;lt;h1&amp;gt;
        Welcome to {{ title }}!
      &amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;styleUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Angular&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The previous code is characterised by &lt;em&gt;decorators&lt;/em&gt; like &lt;code&gt;@Component&lt;/code&gt; and &lt;code&gt;@Input&lt;/code&gt;, part of the &lt;em&gt;Angular template declarative syntax&lt;/em&gt; that provides developers with an easy template grammar to both&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;write &lt;em&gt;control flow statements&lt;/em&gt;, like the &lt;code&gt;for loop&lt;/code&gt; and &lt;code&gt;if&lt;/code&gt; &lt;em&gt;conditional statement&lt;/em&gt;,&lt;/li&gt;
&lt;li&gt;and make &lt;em&gt;data binding&lt;/em&gt; between the variables declared in the controller and used in the templates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
For most of the developers the &lt;em&gt;binding&lt;/em&gt; is just the use of the same variable name between the template and the controller, but there is a mechanism that manages the &lt;em&gt;change detection&lt;/em&gt; at runtime. This is a great thing and the Angular compiler automatically adds this mechanism. Less boilerplate code, templates are mode readable and less error prone.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Angular runtime&lt;/em&gt; is &lt;em&gt;a collection of JavaScript instructions/functions&lt;/em&gt; able to render a component template into the DOM and to answer to change detection when something in the model has changed (MVC). Everything must be in JavaScript, ready to be run, so the Angular declarative syntax is translated into these instructions.&lt;/p&gt;

&lt;p&gt;To make it more clear try to develop a standard Web Component: when the developer has to deal with the template he must deal with the DOM API to create an element and attach it to the DOM, write some code to detect changes in the model and update the view. In the Angular code there is not trace of these operations since a template is translated into &lt;em&gt;JavaScript imperative code&lt;/em&gt;, a series of JavaScript instructions, part of the Angular runtime, that, when invoked, creates the component in the browser.&lt;/p&gt;

&lt;p&gt;Most of the tedious and repetitive job is done by the Angular compiler in conjunction with the Angular runtime.&lt;/p&gt;
&lt;h3&gt;
  
  
  Compiler enables decoupling &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The developer just writes the Angular modules and components, that is the &lt;em&gt;what&lt;/em&gt;, via the Angular declarative syntax but it does not know/care about the &lt;em&gt;how&lt;/em&gt;, that is how things are executed at runtime: &lt;em&gt;compiler enables to decouple the what from the how&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This approach has multiple advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/Side_effect_(computer_science)"&gt;minimize or eliminate side effects&lt;/a&gt; making the developer life simpler;&lt;/li&gt;
&lt;li&gt;if the Angular rendering architecture evolves, small or null changes are required to use the latest version;&lt;/li&gt;
&lt;li&gt;browsers change more and more often as the EcmaScript hence the &lt;em&gt;how&lt;/em&gt; the templates are rendered can change accordingly optimising web performance for instance;&lt;/li&gt;
&lt;li&gt;templates and decorators can be compiled differently w.r.t. the platform where the code is run such ES5 or ES6 with module support.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Simple project setup &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Angular 9 has been recently released, generate a simple project with Angular 9 running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @angular/cli     // to &lt;span class="nb"&gt;install &lt;/span&gt;the Angular CLI
ng new angular-nine-ivy         // or the name you want
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In case you already have a workspace with some changes you have to commit or stash them, otherwise add the flag &lt;code&gt;--allow-dirty&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you already have the old Angular CLI, it seems the better way is to uninstall the old one and the install the new globally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's compile &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;There are two compiler entry points in the &lt;code&gt;@angular/compiler-cli&lt;/code&gt;: &lt;code&gt;ngtsc&lt;/code&gt; and &lt;code&gt;ngcc&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;ngtsc&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;It is the &lt;a href="https://github.com/angular/angular/blob/master/packages/compiler/design/architecture.md#high-level-proposal"&gt;TypeScript to JavaScript transpiler that reifies the Angular decorators into static properties&lt;/a&gt;. &lt;code&gt;ngc&lt;/code&gt; works like the &lt;code&gt;ngtsc&lt;/code&gt; when Ivy is enabled.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;ngcc&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;It is the Angular Compatibility Compiler that process the NPM library code from the &lt;code&gt;node_modules&lt;/code&gt; folder producing equivalent library code Ivy compatible. &lt;code&gt;ngcc&lt;/code&gt; can also be run by a code loader like Webpack to get packages transpiled on demand instead of written in the &lt;code&gt;node_module&lt;/code&gt; package folder.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;ngc&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Open the &lt;code&gt;package.json&lt;/code&gt; and add the &lt;code&gt;ngc&lt;/code&gt; script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ng&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ng&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ngc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ngc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the &lt;code&gt;tsconfig.json&lt;/code&gt; set &lt;code&gt;"declaration": true,&lt;/code&gt; in order to have the &lt;code&gt;.d.ts&lt;/code&gt; files as well, then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm run ngc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The result of the component compilation is located at &lt;code&gt;dist\out-tsc\src&lt;/code&gt;. The &lt;code&gt;Welcome to Angular!&lt;/code&gt; component is translated into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Angular&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵfac&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;AppComponent_Factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;)();&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵcmp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵdefineComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;selectors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; &lt;span class="na"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="na"&gt;decls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;vars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;consts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-align&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;AppComponent_Template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rf&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵelementStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵelementStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵtext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵelementEnd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵelementEnd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rf&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵadvance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵtextInterpolate1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; Welcome to &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="na"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="cm"&gt;/*@__PURE__*/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵsetClassMetadata&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;
                &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;div style="text-align:center"&amp;gt;
      &amp;lt;h1&amp;gt;
        Welcome to {{ title }}
      &amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;styleUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app.component.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="p"&gt;}]&lt;/span&gt;
    &lt;span class="p"&gt;}],&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt;
        &lt;span class="p"&gt;}]&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt; &lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and then the &lt;code&gt;app.component.d.ts&lt;/code&gt; definition file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;declare&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵfac&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵFactoryDef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵcmp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵComponentDefWithMeta&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Attention&lt;/strong&gt;&lt;br&gt;
By default Ivy is enabled, if you disable it you will get a different compilation output.&lt;/p&gt;
&lt;h3&gt;
  
  
  JIT vs. AoT &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Compiler can work in &lt;em&gt;JiT (Just in Time)&lt;/em&gt; mode, it is delivered along with the application and compiles at runtime. &lt;em&gt;AoT (Ahead of Time) compilation&lt;/em&gt; instead compiles everything at build time making the application faster and it does not required to ship the compiler with the application.&lt;/p&gt;

&lt;p&gt;With Angular 9, thanks to Ivy, the compilation is faster and by default &lt;code&gt;"aot": true&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Compilation models &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Both TypeScript and Angular Compiler preserve important metadata that cannot be part of the emitted &lt;code&gt;.js&lt;/code&gt; files. Angular enhances the &lt;code&gt;.d.ts&lt;/code&gt; files with framework specific metadata to be reused for better component type checking.&lt;/p&gt;
&lt;h3&gt;
  
  
  TypeScript compilation model &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;JavaScript code has no type information, it is just ready to be executed in the browser. The TypeScript compiler has transformed all the &lt;code&gt;.ts&lt;/code&gt; source files but typing information are not totally lost, the definition files help to preserve the interface for future use.&lt;/p&gt;

&lt;p&gt;For instance the file &lt;code&gt;library.ts&lt;/code&gt; is compiled into &lt;code&gt;library.js&lt;/code&gt; and &lt;code&gt;library.d.ts&lt;/code&gt; is produced, it describes the &lt;em&gt;interface&lt;/em&gt;{: .italic-red-text } or &lt;em&gt;public API&lt;/em&gt;{: .italic-red-text } of the library.&lt;/p&gt;

&lt;p&gt;The definition file brings &lt;em&gt;type information&lt;/em&gt;{: .italic-red-text } to help TypeScript to static type check the usage of the library. Fo example, when an application declare a npm dependency library can then import functionality:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;AwesomeLib&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;awesome-lib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// use the lib&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;TypeScript will static type check the use of the library in the &lt;code&gt;app.js&lt;/code&gt; exploiting the &lt;code&gt;library.d.ts&lt;/code&gt; definition file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;declare&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AwesomeLib&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;awesomeMethod&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Angular Ivy compilation model &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;An Angular component has some useful information declared in the decorator like the &lt;code&gt;selector&lt;/code&gt;. These information are really important to use the component elsewhere and static type check the code.&lt;/p&gt;

&lt;p&gt;The Angular Ivy compiler has been improved to not waste this information and to enrich the definition file public interface. For instance, the following Angular component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;awesome-comp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AwesomeComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;will be compiled into JavaScript and the metadata will enrich the definition file as following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;declare&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AwesomeComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ngComponentDef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ng&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ComponentDef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
        &lt;span class="nx"&gt;AwesomeComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;`awesome-comp`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The definition file became the &lt;em&gt;component public API&lt;/em&gt;{: .italic-red-text }. The compiler can exploit it in order to type check the code that will use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;awesome&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;comp&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a value&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;just&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/awesome-comp&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  TypeScript transpiler architecture &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The following diagram, &lt;a href="https://github.com/angular/angular/blob/master/packages/compiler/design/architecture.md#typescript-architecture"&gt;thanks to Angular team&lt;/a&gt;, shows the normal &lt;code&gt;tsc&lt;/code&gt; flow and the steps to transpile a &lt;code&gt;.ts&lt;/code&gt; file into the &lt;code&gt;.js&lt;/code&gt; one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;                                                                |------------|
                           |----------------------------------&amp;gt; | TypeScript |
                           |                                    |   .d.ts    |
                           |                                    |------------|
                           |
|------------|          |-----|               |-----|           |------------|
| TypeScript | &lt;span class="nt"&gt;-parse-&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; | AST | -&amp;gt;transform-&amp;gt; | AST | -&amp;gt;print-&amp;gt; | JavaScript |
|   &lt;span class="nb"&gt;source&lt;/span&gt;   |    |     |-----|       |       |-----|           |   &lt;span class="nb"&gt;source&lt;/span&gt;   |
|------------|    |        |          |                         |------------|
                  |    type-check     |
                  |        |          |
                  |        v          |
                  |    |--------|     |
                  |--&amp;gt; | errors | &amp;lt;&lt;span class="nt"&gt;---&lt;/span&gt;|
                       |--------|
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;parse:&lt;/strong&gt; recursive descent parser that produces the abstract syntax tree (AST);&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;type check:&lt;/strong&gt; perform type analysis on every file, report found error. Not modified by the &lt;code&gt;ngtsc&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AST to AST:&lt;/strong&gt; remove type declarations, convert class into ES5, &lt;code&gt;async&lt;/code&gt; methods, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Extension points &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;TypeScript &lt;code&gt;tsc&lt;/code&gt; provides some extension points to alter its output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CompilerHost.getSourceFile&lt;/code&gt; to modify the source;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CustomTransformers&lt;/code&gt; to alter the list of transforms;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WriteFileCallback&lt;/code&gt; to intercept the output before it is written.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Compilation steps
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;ngtsc&lt;/code&gt; is a wrapper around the &lt;code&gt;tsc&lt;/code&gt;, the TypeScript compiler, that extends and modify the normal compilation flow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XmO4xUL1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kjaxyrcs7dqbyq9hj5m3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XmO4xUL1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kjaxyrcs7dqbyq9hj5m3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The TypeScript transpiler cannot compile the Angular templates and decorators, so the Angular compiler kicks in to &lt;em&gt;reify Angular decorators into static properties&lt;/em&gt;. Once finished the TypeScript compiler can go on producing JavaScript code. In other words &lt;em&gt;the Angular compiler allows the code written in Angular declarative syntax to participate to the TypeScript compilation process&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Program creation
&lt;/h3&gt;

&lt;p&gt;Starting from the &lt;code&gt;tsconfig.json&lt;/code&gt; file, the TypeScript process discover the application source files via the &lt;code&gt;import&lt;/code&gt; statements.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Analysis
&lt;/h3&gt;

&lt;p&gt;The Angular compiler takes all the &lt;code&gt;.ts&lt;/code&gt; files collected and, class by class, looks for Angular declarative syntax code, basically Angular things. The compiler gathers isolation information about components for instance, but not about modules. &lt;em&gt;Remember&lt;/em&gt;, for the &lt;code&gt;@Component&lt;/code&gt; the compiler requires a global knowledge about the module due transitive closure resolution of the exports of the component module template imports used in the component template.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Resolve
&lt;/h3&gt;

&lt;p&gt;The Angular compiler looks again at the whole application but this time in a larger picture including modules as well. All the code now is understandable and parsable by the next step of the TypeScript compiler. Optimizations will take place at this step.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Type checking
&lt;/h3&gt;

&lt;p&gt;TypeScript checks error in the application, templates included, that now are a series of imperative instructions.&lt;/p&gt;
&lt;h3&gt;
  
  
  5. Emit
&lt;/h3&gt;

&lt;p&gt;The most expensive operation in the compilation process, the TypeScript code is transformed into JavaScript ready to be run by the browser. Angular component classes have now only imperative code to describe what a template looks like.&lt;/p&gt;
&lt;h2&gt;
  
  
  Compiler features &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Angular compiler has many interesting features, some of them have been enhanced and improved with the new Angular Ivy architecture. Let's see some of them.&lt;/p&gt;
&lt;h3&gt;
  
  
  Module compilation scope &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The module scope allows the compiler to resolve &lt;em&gt;uniquely&lt;/em&gt; the Angular components used by the application. Consider the following application module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;HelloComponent&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The module decorator property &lt;code&gt;declarations&lt;/code&gt; is the &lt;em&gt;module compilation scope&lt;/em&gt;, it holds an array of Angular components used in the application templates. The &lt;code&gt;HelloComponent&lt;/code&gt; is a component coming from a library with its own definition file enriched with metadata as seen before.&lt;/p&gt;

&lt;p&gt;The developer declares the willingness to use the component in the array, then can use the component adding the corresponding selector in one of the application templates.&lt;/p&gt;

&lt;p&gt;The compiler can than uniquely match the component, verify the use of the selectors along with its attributes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Export compilation scope &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A module can be used to export Angular components as a method to make visible the external world some implemented components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The module pattern is quite frequently used in computer languages as a way to separate a complex application in small chunks that can be reused elsewhere. Just think about ESM or CommonJS etc. Angular provides a way to create a modular application via the module concept as well. A module is used also to hide implementation details and to select what should be &lt;em&gt;public&lt;/em&gt;. The &lt;code&gt;exports&lt;/code&gt; property is the way chosen to make Angular component public so re-usable by the rest of the world.&lt;/p&gt;

&lt;p&gt;In the following example the &lt;code&gt;HelloModule&lt;/code&gt; both declares and exports the &lt;code&gt;HelloWorld&lt;/code&gt; component. The module library just implements one component and exports it to all the applications that want to use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;declaration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;HelloComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;HelloComponent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;HelloModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When an application wants to use the &lt;code&gt;HelloWorld&lt;/code&gt; component has just to declare it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;HelloComponent&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The compiler then can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;uniquely find the component definition;&lt;/li&gt;
&lt;li&gt;figure out from the template which components are used;&lt;/li&gt;
&lt;li&gt;generate the code and reference it accordingly;&lt;/li&gt;
&lt;li&gt;help the tree-shaker to remove things that are not referenced.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Partial evaluation &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Compiler actually attempt to almost run TypeScript code in decorators&lt;/p&gt;

&lt;p&gt;Alex Rickabaugh - Angular Connect 2019&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Angular compiler contains almost a complete &lt;em&gt;TypeScript interpreter&lt;/em&gt;. In the following example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;SOME_MODULES&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./some_module&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;HelloComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ByeComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;HelloComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ByeComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;SOME_MODULES&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AnotherModuel&lt;/span&gt; &lt;span class="p"&gt;{...}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;the compiler can follow and evaluate the &lt;em&gt;import references&lt;/em&gt;. Some evaluation are just partial since there are not enough information at compiler time.&lt;/p&gt;

&lt;p&gt;For instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;SOME_MODULES&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./some_module&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SOME_MODULES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SOME_MODULES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;HelloModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ByeModule&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="c1"&gt;// not available at compile time&lt;/span&gt;
    &lt;span class="na"&gt;viewportSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollWidth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollHeight&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;only &lt;em&gt;at runtime&lt;/em&gt; some values will available. This value are &lt;em&gt;dynamic expressions&lt;/em&gt;. The compiler sees the previous object more or less like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;SOME_MODULES&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;modules&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="nx"&gt;Reference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;HelloModule&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nx"&gt;Reference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ByeModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;viewportSize&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DynamicValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollWidth&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DynamicValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollHeight&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;where: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SOME_MODULES&lt;/code&gt; is an object with two properties;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DynamicValue&lt;/code&gt; is an &lt;em&gt;indicator&lt;/em&gt; to say &lt;em&gt;"cannot get past"&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The compilation does not stop, it goes on since a situation like this could be quite common.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;SOME_MODULES&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./some_module&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`
        :host {
            width: $SOME_MODULES.viewportSize.x
        }
    `&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;While the compilation goes on for &lt;code&gt;modules&lt;/code&gt; properties, it cannot for &lt;code&gt;viewportSize&lt;/code&gt; since the value cannot be figured out. An explicative error message is produced about styles.&lt;/p&gt;

&lt;h3&gt;
  
  
  Template type checking &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A template and expressions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;account-view&lt;/span&gt;
    &lt;span class="na"&gt;[account]=&lt;/span&gt;&lt;span class="s"&gt;"getAccount(user.id, 'primary') | async"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/account-view&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;they are compiled into TypeScript code becoming &lt;em&gt;type check blocks&lt;/em&gt;. So blocks are sent to TypeScript compiler and possible errors are then return &lt;em&gt;in the context of the template&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;typeCheckBlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;cmp&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AccountViewCmp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ng&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AsyncPipe&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nx"&gt;cmp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;account&lt;/span&gt; &lt;span class="cm"&gt;/*273,356*/&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getAccount&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="cm"&gt;/*311,315*/&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="cm"&gt;/*311,318*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="cm"&gt;/*320,329*/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="cm"&gt;/*300,331*/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="cm"&gt;/*300,338*/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="cm"&gt;/*289,339*/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;How is it possible to return an error in the context of a template? Well, code is translated with additional &lt;code&gt;offset comments&lt;/code&gt; that allows then the contextualization.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;div style="text-align:center"&amp;gt;
      &amp;lt;h1&amp;gt;
        Welcome to {{ title }}!

        &amp;lt;tr *ngFor="let hero of heroes"&amp;gt;
            &amp;lt;td&amp;gt;{{hero.name}}&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
      &amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;styleUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Angular&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nx"&gt;heroes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fake array&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Angular version 9 &lt;em&gt;with Ivy enabled&lt;/em&gt; maintains the behavior of the &lt;code&gt;fullTemplateTypeCheck&lt;/code&gt; flag and introduces a strict mode with the flag &lt;code&gt;strictTemplates&lt;/code&gt; that goes beyond the Angular 8 type checker. Activate the strict mode in the &lt;code&gt;tsconfig.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;angularCompilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fullTemplateTypeCheck&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;strictTemplates&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Re-run the &lt;code&gt;npm run ngc&lt;/code&gt; and get a full better error reported by the compiler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;src/app/app.component.html:7:13 - error NG2339: Property &lt;span class="s1"&gt;'name'&lt;/span&gt; does not exist on &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;

7       &amp;lt;td&amp;gt;&lt;span class="o"&gt;{{&lt;/span&gt;hero.name&lt;span class="o"&gt;}}&lt;/span&gt;&amp;lt;/td&amp;gt;
              ~~~~~~~~~

  src/app/app.component.ts:5:16
    5   templateUrl: &lt;span class="s1"&gt;'./app.component.html'&lt;/span&gt;,
                     ~~~~~~~~~~~~~~~~~~~~~~
    Error occurs &lt;span class="k"&gt;in &lt;/span&gt;the template of component AppComponent.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;More details available on the &lt;a href="https://angular.io/guide/template-typecheck"&gt;template type-check page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusions &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The Angular 9 Ivy rendering architecture introduces a new compiler and a new rendering engine not only to exploit the incremental DOM technique but also a more powerful compiler.&lt;/p&gt;

&lt;p&gt;Ivy is enabled by default, &lt;code&gt;--aot&lt;/code&gt; is the default way of developing since the new compiler is faster than the previous one. Having AoT mode enable by default reduces also the risk of discrepancies between development and production code.&lt;/p&gt;

&lt;p&gt;Ivy compiler goes even further, it has a better type-check making the reported error much more explicative and easier for the developer to identify the root cause of the issue.&lt;/p&gt;

&lt;p&gt;We all are looking forward to see the new compiler applied to Angular Elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  References &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/angular/angular/blob/master/packages/compiler/design/architecture.md"&gt;Compiler architecture (Ivy)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=isb5Ef6yI48"&gt;The theory of Angular Ivy, Alex Richabaugh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=MMPl9wHzmS4"&gt;Angular Ivy by example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=anphffaCZrQ"&gt;Deep dive into the Angular Compiler, Alex Richabaugh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.angularindepth.com/a-deep-deep-deep-deep-deep-dive-into-the-angular-compiler-5379171ffb7a"&gt;deep-dive-compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=QQ2plVD0gDI&amp;amp;feature=youtu.be&amp;amp;t=27m"&gt;deep-dive-compiler video&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://indepth.dev/ivy-engine-in-angular-first-in-depth-look-at-compilation-runtime-and-change-detection/"&gt;Ivy engine in Angular&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Angular Compiler Architecture
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/angular/angular/blob/master/packages/core/src/render3/STATUS.md"&gt;Angular Compiler status&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/angular/angular/blob/master/packages/compiler/design/architecture.md"&gt;Angular Compiler Architecture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/angular/angular/blob/master/packages/compiler/design/separate_compilation.md"&gt;Angular separate compilation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/angular/angular/blob/master/packages/core/src/render3/STATUS.md"&gt;Angular compiler implementation status&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/angular/tsickle"&gt;Tsickle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/terser/terser"&gt;Terser&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Angular 8 Bootstrap in deep</title>
      <dc:creator>Eugenio Lentini</dc:creator>
      <pubDate>Mon, 23 Dec 2019 19:09:48 +0000</pubDate>
      <link>https://forem.com/eugeniolentini/angular-8-bootstrap-in-deep-3g07</link>
      <guid>https://forem.com/eugeniolentini/angular-8-bootstrap-in-deep-3g07</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Slides&lt;/li&gt;
&lt;li&gt;Lingo&lt;/li&gt;
&lt;li&gt;The plan&lt;/li&gt;
&lt;li&gt;
Browser DOM

&lt;ul&gt;
&lt;li&gt;DOM rendering is slow&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Virtual DOM

&lt;ul&gt;
&lt;li&gt;What Virtual DOM looks like&lt;/li&gt;
&lt;li&gt;How React uses the virtual DOM&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Incremental DOM&lt;/li&gt;
&lt;li&gt;
Angular compiler

&lt;ul&gt;
&lt;li&gt;Angular component&lt;/li&gt;
&lt;li&gt;Browser cannot render an Angular component&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Angular vs. browser

&lt;ul&gt;
&lt;li&gt;Browser role&lt;/li&gt;
&lt;li&gt;Angular role&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Analyze the compiled code

&lt;ul&gt;
&lt;li&gt;Set up the compilation task&lt;/li&gt;
&lt;li&gt;One and simple component&lt;/li&gt;
&lt;li&gt;Module factory function&lt;/li&gt;
&lt;li&gt;What is going to happen&lt;/li&gt;
&lt;li&gt;Component factory function&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
How Angular application bootstraps

&lt;ul&gt;
&lt;li&gt;0. IIEF&lt;/li&gt;
&lt;li&gt;1. Platform&lt;/li&gt;
&lt;li&gt;2. Application&lt;/li&gt;
&lt;li&gt;3. Root component&lt;/li&gt;
&lt;li&gt;4. Create nodes&lt;/li&gt;
&lt;li&gt;5. The renderer&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Conclusions&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Angular bootstrap sequence starts after the load of the &lt;code&gt;index.html&lt;/code&gt; and the JavaScript bundles produced by Webpack. &lt;em&gt;Angular Runtime&lt;/em&gt; creates the &lt;em&gt;platform&lt;/em&gt; where the &lt;em&gt;application&lt;/em&gt; can be started and finally the root component is rendered.&lt;/p&gt;

&lt;p&gt;What follows is related to Angular View Engine and experimented on &lt;em&gt;Angular 8.2.9&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;View Engine is going to be replaced by Angular Ivy in version 9, detail introduction can be found in this other blog post&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/eugeniolentini" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qdSOHU2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--AzOlxhmz--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/123409/8dc27b27-1999-4bf4-bcfd-963ada28af91.jpeg" alt="eugeniolentini image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/eugeniolentini/angular-ivy-a-detailed-introduction-oj1" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Angular Ivy: a detailed introduction&lt;/h2&gt;
      &lt;h3&gt;Eugenio Lentini ・ Dec 10 '19 ・ 14 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#angular&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;&lt;br&gt;
The post contains the thoughts of a preliminary investigation on how Angular works reading some parts of the source code, debugging a simple application and reading how the compiler works. Some terms or definitions could be wrong.&lt;/p&gt;
&lt;h2&gt;
  
  
  Slides &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This post comes along with a &lt;a href="https://blackat.github.io/presentations/docs/angular-bootstrap-deep/index.html"&gt;presentation&lt;/a&gt; written in markdown, rendered via &lt;a href="https://github.com/hakimel/reveal.js/"&gt;&lt;code&gt;reveal.js&lt;/code&gt;&lt;/a&gt; and available on GitHub.&lt;/p&gt;
&lt;h2&gt;
  
  
  Lingo &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Angular View Engine:&lt;/em&gt;{: .italic-violet-text} Angular rendering architecture (compiler and runtime) introduced in version 4 and substituted with Ivy in Angular version 9.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Angular compiler:&lt;/em&gt;{: .italic-violet-text} compiles templates and decorators into a code the runtime can execute.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Angular runtime:&lt;/em&gt;{: .italic-violet-text} execute the JavaScript code produced by the compiler to run the application.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Object Model (OM):&lt;/em&gt;{: .italic-violet-text} a way to model via object-oriented techniques (objects, classes, interfaces, properties, inheritance, encapsulation, etc) a system for development purpose. For instance, Apache POI implements an OM of Microsoft Excel that manipulates via a Java API.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Data Model (DM):&lt;/em&gt;{: .italic-violet-text} it represents entities at the database level, it deals with table schema, relationships between tables (FKs, PKs) but not advanced object-oriented concepts like inheritance or polymorphism. DM represents how OM classes are stored in a database.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;DOM:&lt;/em&gt;{: .italic-violet-text} an object-oriented representation of an HTML document in a tree fashion that can be manipulated via the DOM API, for instance &lt;code&gt;HTMLButtonElement&lt;/code&gt; is one of the DOM interfaces.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Shadow DOM:&lt;/em&gt;{: .italic-violet-text} it allows to separate DOM into smaller and encapsulated object-oriented representations of a HTML element.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Tree and nodes:&lt;/em&gt;{: .italic-violet-text} the DOM is organized in a logical tree where its nodes are the components or HTML elements.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Rendering/painting:&lt;/em&gt;{: .italic-violet-text} the browser process that transform the DOM into the UI.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Virtual DOM:&lt;/em&gt;{: .italic-violet-text} the virtual representation of the real DOM.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Diffing:&lt;/em&gt;{: .italic-violet-text} operation that compare two Virtual DOM.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Incremental DOM:&lt;/em&gt;{: .italic-violet-text} a technique to render and update an Angular component when change detection is fired.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The plan &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Hello Reader, this is a long post so feel free to skip certain sections I have used to introduce and give a more complete context to the Angular bootstrap sequence that is the goal :bowtie:&lt;/p&gt;

&lt;p&gt;The post starts with an introduction about the DOM and two &lt;em&gt;rendering strategies&lt;/em&gt;{: .italic-red-text} used to speed up the page repainting. The &lt;em&gt;incremental DOM&lt;/em&gt; strategy is the base of the Angular rendering architecture.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Welcome to Angular&lt;/code&gt; simple application will help to introduce and talk about the &lt;em&gt;Angular compiler&lt;/em&gt;, why and how the &lt;em&gt;Angular declarative syntax&lt;/em&gt; is transformed into JavaScript code that can be executed by the &lt;em&gt;Angular runtime&lt;/em&gt; in the browser. A deep look into the generated code and the Angular source code will show how the framework creates the DOM element and answer to change detection.&lt;/p&gt;

&lt;p&gt;Some of the content and mechanisms has been changed with the introduction of the new rendering architecture called Angular Ivy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Browser DOM &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The Document Object Model (DOM) connects web pages to scripts or programming languages by representing the structure of a document such as the HTML representing a web page in memory.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;MDN&lt;/cite&gt; - Mozilla Developer Network&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The HTML document is represented in an object-oriented fashion, as objects in a logical tree, by the DOM that also provides the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model"&gt;API&lt;/a&gt; to manipulate those objects.&lt;/p&gt;

&lt;p&gt;The DOM rendered gives the HTML page visible to the end-user.&lt;/p&gt;
&lt;h3&gt;
  
  
  DOM rendering is slow &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Being the DOM represented as a tree, it makes easier to change and update it. What the user sees is the result of the DOM rendering operation that is the &lt;em&gt;slow part&lt;/em&gt;. More a page or a component is complex more could take time to render it.&lt;/p&gt;

&lt;p&gt;A page is usually made of many components, complex and non-complex. Every time one of them changes the all page (or a big part of it) needs to be re-rendered, a really expensive operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
Frequent DOM manipulations make the user interface slow since the re-painting of the user interface is the most expensive part. In general, it is something that is not considered when the page is going to be implemented. For instance, changing the visibility of an element forces the browser to verify/check the visibility of all other DOM nodes.&lt;/p&gt;

&lt;p&gt;Actions like changing visibility or the background of an element trigger a repaint. A simple click of the user could correspond to many different actions behind the scene and so many repainting actions slowing down the web page.&lt;/p&gt;

&lt;p&gt;Two different techniques have been developed to overcome the rendering issue for complex web applications: &lt;em&gt;Virtual DOM&lt;/em&gt; and &lt;em&gt;Incremental DOM&lt;/em&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Virtual DOM &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The key idea is to &lt;em&gt;render the DOM the least possible&lt;/em&gt;{: .italic-red-text }. When a change detection occurs, instead of updating the real DOM, frameworks like React updates a &lt;em&gt;Virtual DOM&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The Virtual DOM is a &lt;em&gt;tree&lt;/em&gt; as well, made of &lt;em&gt;nodes&lt;/em&gt; that are the page elements. When a new element is added/removed a new Virtual DOM is created, the &lt;em&gt;difference&lt;/em&gt; between the two trees is calculated.&lt;/p&gt;

&lt;p&gt;A transformations series is calculated to update the browser DOM so that it &lt;em&gt;matches&lt;/em&gt;{: .italic-red-text } the latest new Virtual DOM. These transformations are both the minimal operations to be applied to the real DOM and the ones that reduce the performance cost of the DOM update.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Internals&lt;/strong&gt;&lt;br&gt;
The rendering process happens only on the &lt;em&gt;difference&lt;/em&gt;. The &lt;em&gt;bulk changes&lt;/em&gt; to be applied are optimized to improve the performance cost.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Amed1byU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2havx06r1ucma7jfi3c4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Amed1byU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2havx06r1ucma7jfi3c4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What Virtual DOM looks like &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The Virtual DOM is something &lt;em&gt;not official&lt;/em&gt;, no specification is provided &lt;em&gt;differently&lt;/em&gt; from DOM and shadow DOM.&lt;/p&gt;

&lt;p&gt;It is a &lt;em&gt;copy&lt;/em&gt; of the original DOM as a &lt;em&gt;plain JavaScript object (JSON)&lt;/em&gt; so that it can be modified how many times we want without affecting the real DOM. Virtual DOM can be divided in chunks so that it is easier to &lt;em&gt;diffing&lt;/em&gt; the changes.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;When a new item is added to an unordered list of elements a copy of the Virtual DOM containing the new element is created.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;diffing&lt;/em&gt; process collects the differences between the two Virtual DOM objects so changes can be transformed in a bulk update against the real DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
No distinction about &lt;em&gt;reflow&lt;/em&gt; (element layout that is position recalculation and geometry) and &lt;em&gt;repaint&lt;/em&gt; (element visibility) has been done so far since most of the considered actions involve the repaint operation.&lt;/p&gt;
&lt;h3&gt;
  
  
  How React uses the Virtual DOM &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In React a user interface is made of a set of components, each component has a &lt;em&gt;state&lt;/em&gt;. For instance, the state of a drop-down menu is the array of the available elements and the current selected one.&lt;/p&gt;

&lt;p&gt;Via the &lt;a href="https://www.baeldung.com/java-observer-pattern"&gt;observer pattern&lt;/a&gt; React listens to &lt;em&gt;state change&lt;/em&gt; to update the Virtual DOM. The &lt;em&gt;diffing&lt;/em&gt; process makes React aware of which Virtual DOM objects have changed, &lt;em&gt;only&lt;/em&gt; those objects will be updated in the real DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
As the developer you don't need to be aware of about how DOM manipulation happens at each state change. React does the job optimizing the performance cost behind the scenes.&lt;/p&gt;

&lt;p&gt;React reduces the re-painting cost applying updates in bulk &lt;em&gt;not&lt;/em&gt; at every single state change.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;great advantage&lt;/em&gt; of using the Virtual DOM is that we don't need any compiler. JSX, for instance, is really close to JavaScript, the key point is &lt;em&gt;the render function&lt;/em&gt; that can be implemented using any programming language.&lt;/p&gt;
&lt;h3&gt;
  
  
  Virtual DOM drawbacks &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Virtual DOM required an &lt;em&gt;interpreter&lt;/em&gt; to interpret the component. At compile time no way exists to know which parts of the interpreter will be required at runtime, so the &lt;em&gt;whole stuff&lt;/em&gt; has to be loaded by the browser.&lt;/li&gt;
&lt;li&gt;Every time there is a change, a new Virtual DOM has to be created, maybe a chunk and not the whole tree, but &lt;em&gt;the memory footprint is high&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Incremental DOM &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The key idea of the incremental DOM is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Every component gets compiled into a series of instructions. These instructions create DOM trees and update them in-place when the data changes.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Victor Savkin&lt;/cite&gt; - &lt;a href="https://blog.nrwl.io/understanding-angular-ivy-incremental-dom-and-virtual-dom-243be844bf36"&gt;Understanding incremental DOM&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each component is then compiled into &lt;em&gt;two main instruction sequences&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;view creation:&lt;/em&gt; invoked the first time the page is rendered, add the component to the DOM;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;change detection:&lt;/em&gt; invoked at every state change to update the component into the DOM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The advantages of the Incremental DOM are a low memory footprint and a skinny interpreter/runtime tailored on the compiled application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular Ivy&lt;/strong&gt;&lt;br&gt;
The Incremental DOM strategy is already present in the Angular View Engine. As it will be shown, each component is compiled into a creation function and an update function. Angular Ivy goes further, it allows the &lt;em&gt;tree-shaking&lt;/em&gt; of the Angular runtime that is not possible with the current rendering architecture.&lt;/p&gt;
&lt;h2&gt;
  
  
  Angular compiler &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;An Angular application is mainly made by &lt;em&gt;Angular components&lt;/em&gt; organized in a tree fashion. Each component is implemented to accomplish a certain mission, for instance, the navigation bar, the drop-down menu, etc.&lt;/p&gt;
&lt;h3&gt;
  
  
  Angular component &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;An Angular component is characterized by a class, &lt;em&gt;TypeScript code&lt;/em&gt; that expresses the &lt;em&gt;logic&lt;/em&gt;, and a decorator that allows defining some &lt;em&gt;metadata&lt;/em&gt; such as the &lt;code&gt;selector&lt;/code&gt;, the &lt;code&gt;template&lt;/code&gt;, etc. The &lt;em&gt;HTML template&lt;/em&gt; represents the &lt;em&gt;presentation layer&lt;/em&gt; of the component and it is implemented using a specific &lt;em&gt;Angular declarative syntax&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
When the developer writes a component uses TypeScript and the Angular declarative syntax for the template to &lt;em&gt;bind&lt;/em&gt; a variable from the logic to the presentation layer and vice versa. Pay attention that &lt;em&gt;no change detection&lt;/em&gt; is required to be added. Change detection works at runtime thanks to the compiler that adds it during the compilation phase.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;Consider a very simple component, the template can be inline or separated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;templateUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app.component.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;styleUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app.component.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a simple component&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A &lt;em&gt;template&lt;/em&gt; is a bunch of HTML code with binding variables to &lt;em&gt;present&lt;/em&gt;{: .italic-red-text }, with a certain look and feel, some content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"text-align:center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;
    Welcome to {{ title }}!
  &lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Browser cannot render an Angular component &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The browser is the &lt;em&gt;execution environment&lt;/em&gt;, it loads the application and executes it. Unfortunately it cannot execute an Angular component &lt;em&gt;as it is&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt; A browser can interpret JavaScript and render HTML but not if written using the &lt;em&gt;Angular declarative syntax&lt;/em&gt;.&lt;br&gt;
Angular provides a compiler that, together with the TypeScript one, transforms &lt;em&gt;"everything in something else"&lt;/em&gt; that a browser can understand.&lt;/p&gt;

&lt;p&gt;During the build of an Angular project, two compilers come into play with &lt;em&gt;different purposes&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tsc&lt;/code&gt; is the TypeScript compiler and generates the JavaScript w.r.t. the target specified in the &lt;code&gt;tsconfig.json&lt;/code&gt;, for instance &lt;code&gt;target: es2015&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ngc&lt;/code&gt; is the Angular compiler that translates the templates and decorators into JavaScript. The Angular compiler can work in two different modes:

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Ahead-of-Time (AoT):&lt;/em&gt; work at build time so that the templates are bundled along with the application, suitable for production.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Just-in-Time (JIT):&lt;/em&gt; templates are not pre-compiled, the compiler comes along with the application, it is loaded by the browser and does the work at runtime, suitable for development.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Internals&lt;/strong&gt; &lt;br&gt;
During the development phase &lt;code&gt;ng serve&lt;/code&gt; provides &lt;em&gt;live reload&lt;/em&gt; functionality.&lt;br&gt;
The process goes through &lt;code&gt;@ngtools/webpack&lt;/code&gt;, compiled code is &lt;em&gt;not saved to disk&lt;/em&gt;, everything is consumed in memory via streams and emitters.&lt;/p&gt;
&lt;h2&gt;
  
  
  Angular vs. browser &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;What are then the &lt;em&gt;roles&lt;/em&gt; of the browser and Angular?&lt;/p&gt;

&lt;p&gt;Once the Angular application has been &lt;em&gt;fully transformed into JavaScript&lt;/em&gt; (HTML templates included), WebPack bundles it along with library dependencies in order to improve performance and load times.&lt;/p&gt;
&lt;h3&gt;
  
  
  Browser role &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;browser role&lt;/em&gt; is to load the &lt;code&gt;index.html&lt;/code&gt; and to provide the execution environment, the render and the event loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    ...
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;app-root&amp;gt;&amp;lt;/app-root&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"runtime-es2015.js"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"polyfills-es2015.js"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"styles-es2015.js"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"vendor-es2015.js"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"main-es2015.js"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

    &lt;span class="c"&gt;&amp;lt;!-- nomodule defer --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"runtime-es5.js"&lt;/span&gt; &lt;span class="na"&gt;nomodule&lt;/span&gt; &lt;span class="na"&gt;defer&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    ...
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The scripts can be loaded both by modern browsers that supports ESM modules and by old ones that do not support modules via &lt;code&gt;nomodule defer&lt;/code&gt; attributes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Angular role &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Consider an Angular application made of only the component previously introduced. The &lt;code&gt;main-es2015.js&lt;/code&gt; contains the fully bundled application while &lt;code&gt;runtime-es2015.js&lt;/code&gt; is the Angular runtime. Finally third party libraries and styles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The transformed HTML template into JavaScript becomes a series of instructions that, once called, &lt;em&gt;render&lt;/em&gt; the page building the components.&lt;br&gt;
Skipping some details, roughly an element is a factory function that uses the &lt;em&gt;injected Angular renderer&lt;/em&gt; to render the element w.r.t. the &lt;em&gt;browser platform&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Angular runtime&lt;/em&gt; bootstraps the &lt;code&gt;AppModule&lt;/code&gt; that, in turn, creates and renders the root element of the application &lt;code&gt;&amp;lt;app-root&amp;gt;&lt;/code&gt;. The file &lt;code&gt;main-es2015.js&lt;/code&gt; contains the &lt;em&gt;view definition factories&lt;/em&gt; produced by the compiler and enriched by Webpack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Internals&lt;/strong&gt;&lt;br&gt;
 If the browser platform is chosen, &lt;code&gt;@angular/platform-browser&lt;/code&gt;, the element will be rendered creating the &lt;code&gt;HTML&lt;/code&gt; code into the DOM via the &lt;code&gt;Document&lt;/code&gt; interface: &lt;code&gt;document.createElement()&lt;/code&gt;. When something changes, the element will update itself calling the update function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular Ivy&lt;/strong&gt;&lt;br&gt;
The compilation process of View Engine produces &lt;code&gt;.metadata.json&lt;/code&gt; and &lt;code&gt;.ngfactory.js&lt;/code&gt; files. With Angular Ivy no more special files are produced, too complex to manage and to merge them. Ivy instructions are directly put into the component, a component knows how to create and update itself.&lt;/p&gt;
&lt;h2&gt;
  
  
  Analyze the compiled code &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Let's see how to compile the application invoking &lt;em&gt;only&lt;/em&gt; the &lt;code&gt;ngc&lt;/code&gt; compiler and nothing else to inspect the compiled code easily and see where the generated JavaScript code invokes the DOM API to create the element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;HTML&lt;/code&gt; template has been compiled into a sequence of JavaScript instructions that will be executed by the Angular runtime. The &lt;em&gt;goal&lt;/em&gt; of the coming sections is to find where the &lt;code&gt;document.createElement()&lt;/code&gt; is invoked after the different Angular entities (platform, application, and component) have been instantiated.&lt;/p&gt;
&lt;h3&gt;
  
  
  Setup the compilation task &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Open the &lt;code&gt;package.json&lt;/code&gt; file and add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compile&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ngc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;then in the &lt;code&gt;tsconfig.json&lt;/code&gt; enable the &lt;code&gt;d.ts&lt;/code&gt; files generation to have the TypeScript definitions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;declaration&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  One and simple component &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Create a new &lt;code&gt;Welcome to Angular&lt;/code&gt; application via the Angular CLI.&lt;/p&gt;

&lt;h4&gt;
  
  
  The module and the component
&lt;/h4&gt;

&lt;p&gt;The &lt;em&gt;module&lt;/em&gt; is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;AppComponent&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;BrowserModule&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="na"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;then the &lt;em&gt;component&lt;/em&gt; of the &lt;code&gt;Welcome to Angular&lt;/code&gt; application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;div style="text-align:center"&amp;gt;
      &amp;lt;h1&amp;gt;
        {% raw %}Welcome to {{ title }}!{% endraw %}
      &amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;styleUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Angular&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Compile
&lt;/h4&gt;

&lt;p&gt;Run the command &lt;code&gt;npm run compile&lt;/code&gt; and look into the folder &lt;code&gt;dist/out-tsc/src/app&lt;/code&gt; where everything has been transformed into JavaScript and &lt;em&gt;saved to disk&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The Angular compiler has produced some files, skip the &lt;code&gt;.metadata&lt;/code&gt; and &lt;code&gt;.d.ts&lt;/code&gt; ones:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;app.module.js               // module class
app.module.ngfactory.js     // module factory, transformed metadata decorator
app.component.js            // component class
app.component.ngfactory.js  // component factory, transformed metadata decorator
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Module factory function &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;app.module.ngfactory.js&lt;/code&gt; contains the &lt;em&gt;factory function creator&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app.module&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i2&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app.component&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i3&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app.component.ngfactory&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;AppModuleNgFactory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵcmf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AppModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_l&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{...}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;&lt;br&gt;
The functions produced by the Angular template compiler start with &lt;code&gt;ɵ&lt;/code&gt; to clearly warn &lt;em&gt;to not use them&lt;/em&gt; because for sure the code will change soon in the future.&lt;/p&gt;

&lt;p&gt;The function &lt;code&gt;ɵcmf&lt;/code&gt; stands for &lt;em&gt;create module factory&lt;/em&gt;, the map between the name and the real function is defined in the following static map object &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/platform-browser-dynamic/src/compiler_reflector.ts#L70"&gt;&lt;code&gt;Map&amp;lt;ExternalReference, any&amp;gt;&lt;/code&gt;&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createBuiltinExternalReferencesMap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ExternalReference&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Identifiers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createModuleFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ɵcmf&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Angular Ivy&lt;/strong&gt;&lt;br&gt;
The aforementioned map object is one of the reasons why the View Engine is not tree-shakable. Angular Ivy should get rid of or change how this static map is defined to allow the runtime to be tree-shaken by any open-source tool.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is going to happen &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The compiler has transformed the decorators, &lt;code&gt;@NgModule&lt;/code&gt; and &lt;code&gt;@Component&lt;/code&gt;, into JavaScript instructions. Now &lt;em&gt;"imagine"&lt;/em&gt; that the TypeScript class has been transpiled into JavaScript and the &lt;code&gt;@Component&lt;/code&gt; decorator that decorates the class became the factory that tells Angular runtime how to create the component into the DOM (&lt;em&gt;create view&lt;/em&gt;) and how to update it (&lt;em&gt;change detection&lt;/em&gt;). The &lt;code&gt;@NgModule&lt;/code&gt; decorators will tell the Angular runtime how to instantiate the application module and get &lt;em&gt;service providers&lt;/em&gt; injected.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;module factory function&lt;/em&gt; will create an &lt;em&gt;application object&lt;/em&gt; that, in turn, will bootstrap the &lt;em&gt;application module&lt;/em&gt; and finally the &lt;em&gt;root component&lt;/em&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Module factory implementation
&lt;/h4&gt;

&lt;p&gt;The module factory function &lt;code&gt;ɵcmf&lt;/code&gt; creates the &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/entrypoint.ts#L35"&gt;module factory object&lt;/a&gt; &lt;code&gt;AppModuleNgFactory&lt;/code&gt; previously shown. here the implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createNgModuleFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;ngModuleType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bootstrapComponents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
    &lt;span class="nx"&gt;defFactory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NgModuleDefinitionFactory&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;NgModuleFactory&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;NgModuleFactory_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ngModuleType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bootstrapComponents&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;defFactory&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;it implements the &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/linker/ng_module_factory.ts#L60"&gt;following interface&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;NgModuleFactory&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nx"&gt;moduleType&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;abstract&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;parentInjector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Injector&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;NgModuleRef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Module creation
&lt;/h4&gt;

&lt;p&gt;The &lt;em&gt;module factory object&lt;/em&gt; can create a &lt;em&gt;module&lt;/em&gt; of type &lt;code&gt;AppModule&lt;/code&gt; defined in the class &lt;code&gt;app.module.js&lt;/code&gt;, that will bootstrap a component of type &lt;code&gt;AppComponent&lt;/code&gt; defined in the file &lt;code&gt;app.component.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;defFactory&lt;/code&gt; is a &lt;em&gt;module defintion function&lt;/em&gt;, &lt;code&gt;ɵmod&lt;/code&gt;, used by the &lt;code&gt;create&lt;/code&gt; method to produce the real module object. It contains an array of &lt;code&gt;ɵmpd&lt;/code&gt; &lt;em&gt;module provider definitions&lt;/em&gt; that, for instance, tell which sanitizer or producer has to be created and injected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;AppModuleNgFactory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵcmf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AppModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_l&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵmod&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵmpd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4608&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DomSanitizer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵDomSanitizerImpl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DOCUMENT&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵmpd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6144&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Sanitizer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DomSanitizer&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵmpd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6144&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;RendererFactory2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵDomRendererFactory2&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Component factory function &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Open &lt;code&gt;app.component.ngfactory.js&lt;/code&gt; and look at &lt;code&gt;ɵccf&lt;/code&gt; or &lt;em&gt;create component factory&lt;/em&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i2&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app.component&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;AppComponentNgFactory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵccf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;i2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="cm"&gt;/* class or type */&lt;/span&gt;
  &lt;span class="nx"&gt;View_AppComponent_Host_0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="cm"&gt;/* factory that produces the app-root, component host, the node defintion */&lt;/span&gt;
  &lt;span class="p"&gt;{},&lt;/span&gt;
  &lt;span class="p"&gt;{},&lt;/span&gt;
  &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;it is defined as &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/refs.ts#L33"&gt;follows&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createComponentFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;componentType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;viewDefFactory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ViewDefinitionFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="nx"&gt;propName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;outputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{[&lt;/span&gt;&lt;span class="nx"&gt;propName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="nx"&gt;ngContentSelectors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]):&lt;/span&gt; &lt;span class="nx"&gt;ComponentFactory&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ComponentFactory_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;componentType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;viewDefFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;outputs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ngContentSelectors&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The factory function is similar to module one except for some more parameters. A component can have &lt;code&gt;@Input()&lt;/code&gt; and &lt;code&gt;@Output&lt;/code&gt; properties and hence the arrays &lt;code&gt;inputs&lt;/code&gt; and &lt;code&gt;outputs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
It starts to be more and more clear how the component declaration is transformed into a set of arguments used by a factory to &lt;em&gt;programmatically&lt;/em&gt; create the component at runtime.&lt;/p&gt;
&lt;h4&gt;
  
  
  Compiled template
&lt;/h4&gt;

&lt;p&gt;What happened to the template? This is why you have read so far... I hope 😅&lt;/p&gt;

&lt;p&gt;The component template has been transformed into a JavaScript object with the &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/types.ts#L53"&gt;following interface&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ViewDefinition&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Definition&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ViewDefinitionFactory&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ViewFlags&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;updateDirectives&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ViewUpdateFn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;updateRenderer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ViewUpdateFn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;handleEvent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ViewHandleEventFn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NodeDef&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="nl"&gt;nodeFlags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NodeFlags&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;rootNodeFlags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NodeFlags&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;lastRenderRootNode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NodeDef&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bindingCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outputCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;nodeMatchedQueries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;view definition&lt;/em&gt; &lt;code&gt;ɵvid&lt;/code&gt; with the &lt;code&gt;app-root&lt;/code&gt; &lt;em&gt;host selector&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;View_AppComponent_Host_0&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_l&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵvid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_l&lt;/span&gt;&lt;span class="p"&gt;()(),&lt;/span&gt;
        &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵeld&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,[],&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;View_AppComponent_0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;RenderType_AppComponent&lt;/span&gt;
        &lt;span class="p"&gt;)),&lt;/span&gt;
      &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵdid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;49152&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kc"&gt;null&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Host selector&lt;/em&gt; since the component is attached/hosted by the selector, the Angular component is a directive, hence the view definition is characterized by (&lt;em&gt;links point to the Angular source code on GitHub&lt;/em&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;element definition&lt;/em&gt;, &lt;code&gt;ɵeld&lt;/code&gt;, the &lt;code&gt;app-root&lt;/code&gt;, the function produces an &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/types.ts#L245"&gt;&lt;code&gt;ElementDef&lt;/code&gt;&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;directive definition&lt;/em&gt;, &lt;code&gt;ɵdid&lt;/code&gt;, the directive that represents the component, the function &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/provider.ts#L30"&gt;&lt;code&gt;directiveDef&lt;/code&gt;&lt;/a&gt; produces an object of type &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/types.ts#L110"&gt;&lt;code&gt;NodeDef&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both produced objects are of type &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/types.ts#L110"&gt;&lt;code&gt;NodeDef&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;element definition&lt;/em&gt; &lt;code&gt;ɵeld&lt;/code&gt; references then &lt;code&gt;View_AppComponent_0&lt;/code&gt;, the other JavaScript code that represents the component template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;View_AppComponent_0&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_l&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵvid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_l&lt;/span&gt;&lt;span class="p"&gt;()(),&lt;/span&gt;
      &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵeld&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_l&lt;/span&gt;&lt;span class="p"&gt;()(),&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Welcome to &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_ck&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;_v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;_co&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;currVal_0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_co&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;_ck&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currVal_0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;ɵvid&lt;/code&gt;, &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/view/view.ts#L23"&gt;&lt;code&gt;viewDef&lt;/code&gt;&lt;/a&gt; function, takes two view update functions: &lt;code&gt;updateDirectives&lt;/code&gt; and &lt;code&gt;updateRenderer&lt;/code&gt; for the change detection along with the function to create the element the first time the application is loaded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
In a view definition function &lt;code&gt;ɵvid&lt;/code&gt; there are two interesting things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;NodeDef[]&lt;/code&gt; array of nodes that is responsible of the view creation;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;updateDirectives&lt;/code&gt; and &lt;code&gt;updateRenderer&lt;/code&gt; functions responsible of the change detection update.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Angular Ivy&lt;/strong&gt;&lt;br&gt;
In Angular Ivy there are no more &lt;code&gt;.ngfactory.js&lt;/code&gt; files, all the required code for &lt;em&gt;view creation&lt;/em&gt; and &lt;em&gt;change detection&lt;/em&gt; is inside the component. Imho the incremental DOM if fully implemented in Ivy, what is missing in View Engine is the possibility to tree-shake the runtime to squeeze it as much as possible.&lt;/p&gt;
&lt;h2&gt;
  
  
  How Angular application bootstraps &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Once the compiled code has been analyzed, it is interesting to see the call sequence to the Angular runtime to find which function renders the component. At the end of the sequence there must be the sought after &lt;code&gt;document.createElement()&lt;/code&gt; function call to the DOM API.&lt;/p&gt;

&lt;p&gt;Build the application and start a live server to debug it into the browser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ng build &lt;span class="nt"&gt;--aot&lt;/span&gt;
npx http-server dist/test-ivy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The Angular AOT compiler extracts metadata to interpret the parts of the application that Angular runtime is supposed to manage.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically, the compiler manages metadata interpretation and template compilation that can be controlled specifying some template compiler options in the &lt;code&gt;tsconfig.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular Ivy&lt;/strong&gt;&lt;br&gt;
Activate the Ahead-of-Time compilation to have everything in JavaScript and &lt;em&gt;saved to disk&lt;/em&gt; make it easier to inspect the generated code. With Angular Ivy &lt;code&gt;--aot&lt;/code&gt; is not necessary anymore since it is activated by default. Ivy compilation is so fast that AoT compilation can be always used.&lt;/p&gt;
&lt;h3&gt;
  
  
  0. IIEF &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The application starts in the file &lt;code&gt;main-es2015.js&lt;/code&gt;. The option &lt;code&gt;--aot&lt;/code&gt; contributes to some optimizations, &lt;code&gt;bootstrapModule&lt;/code&gt; is replaced by &lt;code&gt;bootstrapModuleFactory&lt;/code&gt; as you can observe from the file &lt;a href="https://github.com/angular/angular.io/blob/281efb9ca0d278b36e2e7fa0850a807d7005e50b/public/docs/_examples/upgrade-phonecat-3-router/ts/app/main-aot.ts#L7"&gt;&lt;code&gt;main-aot.ts&lt;/code&gt;&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;platformBrowser&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/platform-browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;AppModuleNgFactory&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app.module.ngfactory&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// *** Follow bootstrapModuleFactory() ***&lt;/span&gt;
&lt;span class="nx"&gt;platformBrowser&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;bootstrapModuleFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AppModuleNgFactory&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Pay attention:&lt;/em&gt; in each piece of code there is a comment that allows following the bootstrap call sequence &lt;code&gt;// *** Follow&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
When invoking the &lt;code&gt;ng build&lt;/code&gt; and not simply the compiler as done before, Webpack bundles what has been produced by the compiler, so opening the files results in a slightly different code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9AYBVWbY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pu9s9pin0bno5sizwwhm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9AYBVWbY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pu9s9pin0bno5sizwwhm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Basically&lt;/em&gt; the IIEF function bootstraps the platform &lt;code&gt;PlatformRef&lt;/code&gt;, that, in turn, instantiates the application &lt;code&gt;ApplicationRef&lt;/code&gt; and then the module along with all the required injectable providers. Finally, the component is created and rendered into the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Internals&lt;/strong&gt;&lt;br&gt;
The application code is composed of &lt;code&gt;app.module.ts&lt;/code&gt; and &lt;code&gt;app.component.ts&lt;/code&gt;. First Angular runtime has to be started, then it creates the &lt;em&gt;platform&lt;/em&gt; linked to the page, starts the &lt;em&gt;application&lt;/em&gt; that is the &lt;em&gt;module&lt;/em&gt;. Once the module has been started the &lt;em&gt;component&lt;/em&gt; can be instantiated and rendered.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Platform &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The Angular platform &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/application_ref.ts#L235"&gt;&lt;code&gt;PlatfromRef&lt;/code&gt;&lt;/a&gt; is the &lt;em&gt;entry point for Angular on a web page&lt;/em&gt;. Each page has &lt;em&gt;exactly one platform&lt;/em&gt; and services bound to its scope. A &lt;em&gt;page's platform&lt;/em&gt; is initialized implicitly when a platform is created via a platform factory (e.g. &lt;code&gt;platformBrowser&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;PlatformRef&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="cm"&gt;/**
     * Creates an instance of an `\@NgModule` for the given platform
     * for offline compilation.
     */&lt;/span&gt;
    &lt;span class="nx"&gt;bootstrapModuleFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;moduleFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Note: We need to create the NgZone _before_ we instantiate the module,&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;ngZone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ngZoneInjector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;moduleFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;moduleType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="c1"&gt;// from here the ApplicationRef is created and available to be injected&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;moduleRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;InternalNgModuleRef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;M&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;moduleFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ngZoneInjector&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="c1"&gt;// *** Follow _moduleDoBootstrap() ***&lt;/span&gt;
        &lt;span class="c1"&gt;// moduleType: *class AppModule*&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_moduleDoBootstrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;moduleRef&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;moduleRef&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
      &lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="cm"&gt;/**
     * Bootstrap all the components of the module
     */&lt;/span&gt;
    &lt;span class="nx"&gt;_moduleDoBootstrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;moduleRef&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;appRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;moduleRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ApplicationRef&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;ApplicationRef&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
      &lt;span class="c1"&gt;// loop over the array defined in the @NgModule, bootstrap: [AppComponent]&lt;/span&gt;
      &lt;span class="nx"&gt;moduleRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_bootstrapComponents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;
        &lt;span class="c1"&gt;// *** Follow bootstrap() ***&lt;/span&gt;
        &lt;span class="c1"&gt;// bootstrap the root component *AppComponent* with selector *app-root*&lt;/span&gt;
        &lt;span class="nx"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;appRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
      &lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Basically&lt;/em&gt; change detection is managed by &lt;a href="https://blog.angularindepth.com/i-reverse-engineered-zones-zone-js-and-here-is-what-ive-found-1f48dc87659b"&gt;&lt;code&gt;Zone.js&lt;/code&gt;&lt;/a&gt; that run the module bootstrap. &lt;code&gt;ApplicationRef&lt;/code&gt; reference is created and then it bootstraps the &lt;code&gt;AppComponent&lt;/code&gt; component.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Application &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://github.com/angular/angular/blob/d2222541e8acf0c01415069e7c6af92b2acbba4f/packages/core/src/application_ref.ts#L503"&gt;&lt;code&gt;ApplicationRef&lt;/code&gt;&lt;/a&gt; reference represents an Angular application &lt;em&gt;running on a page&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;ApplicationRef&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
      &lt;span class="cm"&gt;/**
       * Bootstrap a new component at the root level of the application.
       * When bootstrapping a new root component into an application, Angular mounts the
       * specified application component onto DOM elements identified by the componentType's
       * selector and kicks off automatic change detection to finish initializing the component.
       */&lt;/span&gt;
      &lt;span class="nx"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;componentOrFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rootSelectorOrNode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="cm"&gt;/**
         * Use the componentFactory to create the root element app-root having this information:
         * componentType: class AppComponent
         * viewDefFactory: View_AppComponent_Host_0()
         * selector: app-root
         */&lt;/span&gt;
        &lt;span class="c1"&gt;// *** Follow create() ***&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;compRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;componentFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nx"&gt;selectorOrNode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ngModule&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Root component &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Build the root component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;ComponentFactory_&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;ComponentFactory&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;projectableNodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rootSelectorOrNode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ngModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createRootView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;projectableNodes&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nx"&gt;rootSelectorOrNode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;viewDef&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ngModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;EMPTY_CONTEXT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Basically&lt;/em&gt; the Angular &lt;a href="https://github.com/angular/angular/blob/d192a7b47a265aee974fb29bde0a45ce1f1dc80c/packages/core/src/linker/component_factory.ts#L79"&gt;&lt;code&gt;component_factory.ts&lt;/code&gt;&lt;/a&gt; holds the base class method to create a component of a certain type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;ComponentFactory_&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;ComponentFactory&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="na"&gt;viewDefFactory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ViewDefinitionFactory&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="cm"&gt;/**
   * Creates a new component.
   */&lt;/span&gt;
  &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="na"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Injector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;projectableNodes&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;[][],&lt;/span&gt; &lt;span class="nx"&gt;rootSelectorOrNode&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;ngModule&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;NgModuleRef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;ComponentRef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;ngModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ngModule should be provided&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;viewDef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resolveDefinition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;viewDefFactory&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;componentNodeIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;viewDef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;componentProvider&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nodeIndex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// *** Follow createRootView() ***&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createRootView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;projectableNodes&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nx"&gt;rootSelectorOrNode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;viewDef&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ngModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;EMPTY_CONTEXT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;asProviderData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;componentNodeIndex&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rootSelectorOrNode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;asElementData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;renderElement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ng-version&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;VERSION&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;full&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ComponentRef_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ViewRef_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Basically&lt;/em&gt; the implementation uses the function &lt;code&gt;resolveDefinition()&lt;/code&gt; to load the view definition. This function will be used many times around the code. The &lt;code&gt;createRootView()&lt;/code&gt; function creates a &lt;code&gt;ViewData&lt;/code&gt; object that contains the information that will be used later on to render the node into the DOM.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Create nodes &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The code is going to arrive at the point where the DOM API is called to create and attach the element to the DOM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createRootView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;def&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;def&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;initView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// *** Follow createViewNodes() ***&lt;/span&gt;
  &lt;span class="nx"&gt;createViewNodes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;the function &lt;a href="https://github.com/angular/angular/blob/d192a7b47a265aee974fb29bde0a45ce1f1dc80c/packages/core/src/view/view.ts#L250"&gt;&lt;code&gt;function createViewNodes(view: ViewData){...}&lt;/code&gt;&lt;/a&gt; creates a DOM element w.r.t. its type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createViewNodes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nodes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;def&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nodeDef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;201347067&lt;/span&gt; &lt;span class="cm"&gt;/* Types */&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="cm"&gt;/* TypeElement */&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;// H1 DOM element of type any, the function calls the DOM renderer to render the element&lt;/span&gt;
        &lt;span class="c1"&gt;// *** Follow createElement() ***&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;renderHost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;nodeDef&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="c1"&gt;// View_AppComponent_0()&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;compViewDef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resolveDefinition&lt;/span&gt;&lt;span class="p"&gt;(((&lt;/span&gt;&lt;span class="nx"&gt;nodeDef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;componentView&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="cm"&gt;/* TypeText */&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  5. The renderer &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://github.com/angular/angular/blob/d192a7b47a265aee974fb29bde0a45ce1f1dc80c/packages/core/src/view/element.ts#L151"&gt;&lt;code&gt;createElement&lt;/code&gt;&lt;/a&gt; function will use the injected renderer to create the element.w.r.t. the platform where the application runs.&lt;/p&gt;

&lt;p&gt;In case of &lt;code&gt;PlatformBrowser&lt;/code&gt;, the &lt;a href="https://github.com/angular/angular/blob/d192a7b47a265aee974fb29bde0a45ce1f1dc80c/packages/platform-browser/src/dom/dom_renderer.ts#L115"&gt;&lt;code&gt;DefaultDomRenderer2&lt;/code&gt;&lt;/a&gt; class invokes the &lt;code&gt;document&lt;/code&gt; interface method to create the real DOM element. &lt;code&gt;DefaultDomRenderer2&lt;/code&gt; extends and implements &lt;a href="https://github.com/angular/angular/blob/d192a7b47a265aee974fb29bde0a45ce1f1dc80c/packages/core/src/render/api.ts#L108"&gt;&lt;code&gt;abstract class Renderer2&lt;/code&gt;&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// In cases where Ivy (not ViewEngine) is giving us the actual namespace, the look up by key&lt;/span&gt;
      &lt;span class="c1"&gt;// will result in undefined, so we just return the namespace here.&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElementNS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;NAMESPACE_URIS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// *** FOUND ***&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt; &lt;br&gt;
An HTML template is transformed in an &lt;em&gt;intermediate&lt;/em&gt; format or Object Model by the Angular compiler.&lt;br&gt;
Factory functions are automatically generated by the compiler and they are able to produce an object that can create a component or a node or a module. Then a renderer, specified by the chosen platform, will produce DOM elements in case of a DOM renderer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusions &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;It has been shown how the Angular compiler transforms the Angular declarative syntax and the decorators into something the Angular runtime can execute. The Angular compiler and the runtime constitute the rendering architecture.&lt;/p&gt;

&lt;p&gt;A developer can use a simple syntax without worrying about change detection and performance optimization w.r.t. the DOM updates since the Angular framework, behind the scenes, does all the job. When new optimizations are available can be got transparently and effortlessly.&lt;/p&gt;

&lt;p&gt;One of the big issues with the current rendering architecture, View Engine, is to not be tree-shakable and difficult to expand. Angular Ivy will solve all these issues being composed by an &lt;em&gt;instruction set&lt;/em&gt; that can be easily expanded and tree-shaken to avoid the delivery of the full Angular runtime to the browser as today.&lt;/p&gt;

&lt;h2&gt;
  
  
  References &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;h4&gt;
  
  
  DOM
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://bitsofco.de/understanding-the-critical-rendering-path/"&gt;Understanding the critical rendering path&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model"&gt;Document Object Model (DOM)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bitsofco.de/what-exactly-is-the-dom/"&gt;What exactly is the DOM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Virtual DOM
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://programmingwithmosh.com/react/react-virtual-dom-explained/"&gt;React Virtual Dom&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bitsofco.de/understanding-the-virtual-dom/"&gt;Understanding the Virtual Dom&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Angular compiler
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.angularindepth.com/a-deep-deep-deep-deep-deep-dive-into-the-angular-compiler-5379171ffb7a"&gt;Deep dive into the Angular compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=QQ2plVD0gDI&amp;amp;feature=youtu.be&amp;amp;t=27m"&gt;Deep dive into the Angular compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=RXYjPYkFwy4"&gt;The Angular Compiler 4.0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=tBV4IQwPssU"&gt;Mad science with the Angular Compiler&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Incremental DOM and Ivy
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.angularindepth.com/inside-ivy-exploring-the-new-angular-compiler-ebf85141cee1"&gt;Inside Ivy: Exploring the New Angular Compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.nrwl.io/understanding-angular-ivy-incremental-dom-and-virtual-dom-243be844bf36"&gt;Understanding Angular Ivy: Incremental DOM and Virtual DOM&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://google.github.io/incremental-dom/"&gt;Incremental DOM&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://google.github.io/incremental-dom/#why-incremental-dom"&gt;Why incremental DOM&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/google-developers/introducing-incremental-dom-e98f79ce2c5f"&gt;Introducing Incremental DOM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Zone
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.angularindepth.com/i-reverse-engineered-zones-zone-js-and-here-is-what-ive-found-1f48dc87659b"&gt;I reverse-engineered Zones (zone.js) and here is what I’ve found&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Angular Ivy: a detailed introduction</title>
      <dc:creator>Eugenio Lentini</dc:creator>
      <pubDate>Tue, 10 Dec 2019 20:15:46 +0000</pubDate>
      <link>https://forem.com/eugeniolentini/angular-ivy-a-detailed-introduction-oj1</link>
      <guid>https://forem.com/eugeniolentini/angular-ivy-a-detailed-introduction-oj1</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Slides&lt;/li&gt;
&lt;li&gt;Lingo&lt;/li&gt;
&lt;li&gt;
Rendering architecture

&lt;ul&gt;
&lt;li&gt;Virtual DOM&lt;/li&gt;
&lt;li&gt;Incremental DOM&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Enable Angular Ivy

&lt;ul&gt;
&lt;li&gt;Enable Ivy in an existing project&lt;/li&gt;
&lt;li&gt;New project with Ivy&lt;/li&gt;
&lt;li&gt;Disable Ivy&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Angular Ivy compilation&lt;/li&gt;

&lt;li&gt;

What Angular Ivy enables

&lt;ul&gt;
&lt;li&gt;Tree-shaking&lt;/li&gt;
&lt;li&gt;Incremental compilation&lt;/li&gt;
&lt;li&gt;Locality&lt;/li&gt;
&lt;li&gt;Example: Ivy library compilation&lt;/li&gt;
&lt;li&gt;Flexibility&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Angular Ivy build pipeline&lt;/li&gt;

&lt;li&gt;Component lazy loading feature&lt;/li&gt;

&lt;li&gt;Bundle size&lt;/li&gt;

&lt;li&gt;Debugging&lt;/li&gt;

&lt;li&gt;Conclusions&lt;/li&gt;

&lt;li&gt;References&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Angular Ivy is the new &lt;em&gt;rendering architecture&lt;/em&gt; that comes, by default, with version Angular 9. The Angular rendering architecture is not new to a complete revamp, Angular 2.0, Angular 4.0 and now Angular 9.0 have introduced new &lt;em&gt;compilers&lt;/em&gt; and &lt;em&gt;runtime engines&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Currently, Angular stable version is 8.2.14 and Angular 9 is in RC5.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;&lt;br&gt;
The post contains the thoughts of a preliminary investigation on how Angular works reading some parts of the source code, debugging a simple application and reading how the compiler works. Some terms or definition could be wrong.&lt;/p&gt;
&lt;h2&gt;
  
  
  Slides &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This post comes along with a &lt;a href="https://blackat.github.io/presentations/docs/angular-ivy/index.html" rel="noopener noreferrer"&gt;presentation&lt;/a&gt; written in markdown, rendered via &lt;a href="https://github.com/hakimel/reveal.js/" rel="noopener noreferrer"&gt;&lt;code&gt;reveal.js&lt;/code&gt;&lt;/a&gt; and available on GitHub.&lt;/p&gt;
&lt;h2&gt;
  
  
  Lingo &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Rendering architecture:&lt;/em&gt; compiler and runtime engine pipeline that allows an Angular application to be executed.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Runtime rendering function set/instruction set:&lt;/em&gt; set of JavaScript functions understandable by runtime, templates, and decorators are transformed into a sequence of instructions.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Virtual DOM and incremental DOM:&lt;/em&gt; techniques to create and update a component in the DOM.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;View Engine:&lt;/em&gt; rendering architecture introduced in Angular 4,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;angular.json&lt;/code&gt; is the workspace or build configuration file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tsconfig.app.json&lt;/code&gt; is the project configuration file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.ngfactory.js&lt;/code&gt; suffix for decorator factory files, class decorators like &lt;code&gt;@Component&lt;/code&gt; is translated by the compiler into external files.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Locality:&lt;/em&gt; compiler should use only information from the component decorator and its class.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Global compilation:&lt;/em&gt; compilation process requires global static analysis to emit the application code.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Rendering Architecture &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;What is rendering architecture? It is the pair &lt;em&gt;compiler:runtime&lt;/em&gt;. Angular framework is composed of two main parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;compiler&lt;/em&gt; to transform templates written in Angular declarative syntax into JavaScript instructions enriched with change detection;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;runtime&lt;/em&gt; to execute the application code produced by the compiler.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Currently, Angular 8 uses as rendering architecture called &lt;em&gt;View Engine&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;View Engine&lt;/strong&gt; has been introduced with Angular version 4 and still used in version 8, but some limitations have been identified

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;no tree-shakable:&lt;/em&gt; both the &lt;code&gt;Hello World&lt;/code&gt; application and a very complex one are executed by the same and full runtime. If the internationalization module is not used, for instance, it is part of the runtime anyhow, basically the runtime it cannot be tree-shakable;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;no incremental compilation:&lt;/em&gt; &lt;em&gt;Angular compilation is global&lt;/em&gt; and it involves not only the application but also the libraries.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ivy&lt;/strong&gt; will the new default rendering engine starting from version 9 and should solve the View Engine current issues:

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;simplify&lt;/em&gt; how Angular works internally;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;tree-shakable&lt;/em&gt;  the &lt;code&gt;Hello World&lt;/code&gt; application does not require the full Angular runtime and will be bundled in only 4.7 KB;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;incremental compilation&lt;/em&gt; is not possible so the compilation is faster than ever and &lt;code&gt;--aot&lt;/code&gt; can be now used even during development mode (advice from Angular team).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Ivy is an enabler.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Igor Minar&lt;/cite&gt; - Angular team&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The incremental DOM is the &lt;a href="https://blog.nrwl.io/understanding-angular-ivy-incremental-dom-and-virtual-dom-243be844bf36" rel="noopener noreferrer"&gt;foundation of the new rendering engine.&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Incremental DOM vs. Virtual DOM
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Every component gets compiled into a series of instructions. These instructions create DOM trees and update them in-place when the data changes.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Viktor Savkin&lt;/cite&gt; - &lt;a href="https://blog.nrwl.io/understanding-angular-ivy-incremental-dom-and-virtual-dom-243be844bf36" rel="noopener noreferrer"&gt;Nrwl&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each compiled component has &lt;em&gt;two main sets of instructions&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;view creation&lt;/em&gt; instructions executed when the component is rendered for the first time;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;change detection&lt;/em&gt; instructions to update the DOM when the component changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Change detection is basically a set of instructions added at compile time. The developer's life is made easier since he is aware only of the variable &lt;em&gt;binding&lt;/em&gt; in the Angular template declarative.&lt;/p&gt;

&lt;p&gt;Incremental DOM enables &lt;em&gt;better bundle size and memory footprint&lt;/em&gt; so that applications can perform really well on mobile devices.&lt;/p&gt;
&lt;h3&gt;
  
  
  Virtual DOM &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Both React and Vue are based on the concept of &lt;em&gt;Virtual DOM&lt;/em&gt; to create a component and re-render it when change detection happens.&lt;/p&gt;

&lt;p&gt;Render the DOM is a very expensive operation when a component is added to the DOM or changes happen, the repaint operation has to take place. Virtual DOM strategy aims to reduce the amount of work on the real DOM and so the number of times the user interface needs to be repainted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The end-user sometimes does not realize the complexity behind the rendering of a user interface. A simple click can generate HTTP requests, changes in the component, changes in other components and so on. Single change for the user can be a complex set of changes that must be applied to the DOM.&lt;/p&gt;

&lt;p&gt;DOM manipulations happens every time a new component is going to be added, removed or changed from the DOM, so instead of operating directly on the DOM it operates on a JSON object called Virtual DOM. When a new component is added or an existing one removed, a new Virtual DOM is created, the node added or removed and the difference between Virtual DOMs is computed. A sequence of transformations is applied to the real DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fg2rs1mqghkvko3r2f1sf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fg2rs1mqghkvko3r2f1sf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React documentation advice is to use JSX, a &lt;em&gt;syntax extension&lt;/em&gt; to JavaScript, to define &lt;em&gt;React elements&lt;/em&gt;. JSX is not a template language. A template is an enriched JavaScript expression that is interpreted at runtime. Plain JavaScript can also be used instead of JSX.&lt;/p&gt;

&lt;p&gt;Virtual DOM technique has some disadvantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create a whole tree every time a change happens (add or remove a node), so the memory footprint is quite important;&lt;/li&gt;
&lt;li&gt;an interpreter is required as long as the &lt;em&gt;diff&lt;/em&gt; algorithm to compute the difference among the Virtual DOMs. At compile time it is not known which functionalities are required to render the application, so &lt;em&gt;the whole thing has to be shipped to the browser&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Incremental DOM &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;It is the foundation of the new rendering engine. Each &lt;em&gt;component template&lt;/em&gt; gets compiled into creation and change detection instructions: one to add the component to the DOM and the other one to update the DOM &lt;em&gt;in-place&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Instructions are &lt;em&gt;not interpreted&lt;/em&gt; by the Angular runtime, the rendering engine, but &lt;em&gt;the instructions are the rendering engine&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Viktor Savkin&lt;/cite&gt; - &lt;a href="https://blog.nrwl.io/understanding-angular-ivy-incremental-dom-and-virtual-dom-243be844bf36" rel="noopener noreferrer"&gt;Nrwl&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since the runtime does not interpret the template component instructions, but the &lt;em&gt;component references instructions&lt;/em&gt; it is quite easy to remove those instructions that are not referenced. At compile time the unused instruction can be excluded from the bundle.&lt;/p&gt;

&lt;p&gt;The amount of memory required to render the DOM is &lt;em&gt;proportional&lt;/em&gt; to the size of the component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The compiled template component references some instructions of the Angular runtime which holds the implementation.&lt;/p&gt;
&lt;h2&gt;
  
  
  Enable Angular Ivy &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Ivy can be enabled in an existing project with the latest Angular version but also directly scaffold a project with Ivy.&lt;/p&gt;
&lt;h3&gt;
  
  
  Enable Ivy in an existing project &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Having an existing &lt;a href="https://angular.io/guide/ivy" rel="noopener noreferrer"&gt;Angular (8.1.x)&lt;/a&gt; project run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ng update @angular/cli@next @angular/core@next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;both the Angular core and the CLI will be updated at the latest release candidate. One interesting thing to notice is the &lt;code&gt;"aot": true&lt;/code&gt; in the &lt;code&gt;angular.json&lt;/code&gt; &lt;em&gt;workspace configuration file&lt;/em&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;AOT compilation with Ivy is faster and should be used by default.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://angular.io/guide/ivy" rel="noopener noreferrer"&gt;Angular docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then add the angular compiler options in the &lt;code&gt;tsconfig.app.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;angularCompilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;enableIvy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  New project with Ivy &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To start a new project with Ivy run:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;new my-app &lt;span class="nt"&gt;--enable-ivy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Disable Ivy &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To disable Ivy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;in &lt;code&gt;angular.json&lt;/code&gt; set &lt;code&gt;"aot": false&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;in &lt;code&gt;tsconfig.app.json&lt;/code&gt; remove the &lt;code&gt;angularCompilerOptions&lt;/code&gt; option or set &lt;code&gt;"enableIvy": false&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Angular Ivy Compilation &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Consider the following &lt;em&gt;Hello World&lt;/em&gt; Angular component:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;div style="text-align:center"&amp;gt;
      &amp;lt;h1&amp;gt;
        Welcome to {{ title }}!
      &amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;styleUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Angular!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;in Angular 8 with Ivy enabled, it gets compiled into the following code:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Angular!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ngComponentDef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defineComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;selectors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;
        &lt;span class="na"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;();}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;elementStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nf"&gt;elementStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nf"&gt;elementEnd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nf"&gt;elementEnd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{...}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="nx"&gt;directives&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...]&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In Angular 8 with Ivy, the Angular decorators were compiled into &lt;em&gt;static fields&lt;/em&gt; in the decorated class. So &lt;code&gt;@Component&lt;/code&gt; becomes &lt;code&gt;ngComponentDef&lt;/code&gt; static field. Back to View Engine, the &lt;code&gt;ngc&lt;/code&gt; compiler produces &lt;code&gt;.ngfactory&lt;/code&gt; separated files for each component and modules. With Ivy the code produced by the compiler is moving into &lt;em&gt;component class static fields&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;elementStart()&lt;/code&gt;, &lt;code&gt;elementEnd()&lt;/code&gt;, etc are the &lt;em&gt;component referenced instructions&lt;/em&gt;, &lt;em&gt;every component is its own factory&lt;/em&gt;, the framework does not interpret the component.&lt;/p&gt;

&lt;p&gt;All the &lt;em&gt;not referenced&lt;/em&gt; instructions at compile time are removed from the final application bundle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbcxy8j56zl8f3m1o9dxv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbcxy8j56zl8f3m1o9dxv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The View Engine runtime is a &lt;em&gt;single monolith interpreter&lt;/em&gt; that is not tree-shakable and has to be entirely shipped to the browser. Differently, &lt;em&gt;Angular Ivy runtime&lt;/em&gt; is an &lt;em&gt;instruction set&lt;/em&gt; that is a &lt;em&gt;set of rendering functions&lt;/em&gt; like an assembly language for templates.&lt;/p&gt;

&lt;p&gt;In Angular 9 RC5 and Ivy instead the compilation is a bit different:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Angular&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵfac&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;AppComponent_Factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;)();&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵcmp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵdefineComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;selectors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app-root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; 
  &lt;span class="na"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="na"&gt;decls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;vars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="na"&gt;consts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-align&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; 
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;AppComponent_Template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rf&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵelementStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵelementStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵtext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵelementEnd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵelementEnd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rf&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵadvance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ɵɵtextInterpolate1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; Welcome to &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;! &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="na"&gt;encapsulation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  What Angular Ivy enables &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Angular Ivy is an enabler.&lt;/em&gt; Simplifying how Angular works internally and the compilation process resolves current View Engine limitations and makes Angular easily extensible to new features.&lt;/p&gt;

&lt;p&gt;The new Ivy engineering has been driven by three main goals: &lt;em&gt;tree-shaking, locality, and flexibility&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Tree-shaking &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Tree-shaking is the operation of removing &lt;em&gt;dead code&lt;/em&gt; from the bundle so if the application does not reference some of the runtime rendering function, they can be omitted from the bundle making it smaller.&lt;/p&gt;

&lt;p&gt;Dead code comes from libraries, Angular included. Angular CLI is powered by &lt;del&gt;Webpack uglify plugin&lt;/del&gt; Webpack Terser plugin as tree-shaker that, in turn, receives information from &lt;em&gt;Angular Build Optimizer Plugin&lt;/em&gt; about which code is used and which not. The Angular compiler simply does not emit those instructions, the plugin can gather information about component referenced instructions so can instruct &lt;del&gt;Uglify&lt;/del&gt; Terser about what to include/exclude in/from the bundle.&lt;/p&gt;

&lt;p&gt;While the &lt;code&gt;@angular/core&lt;/code&gt; framework is tree-shakable, the View Engine runtime is not, it cannot be broken into small pieces and this is mainly due to the static &lt;code&gt;Map&amp;lt;Component, ComponentFactory&amp;gt;&lt;/code&gt; &lt;a href="https://github.com/angular/angular/blob/1d429b216556911edc4b0675ece4cb9081967155/packages/platform-browser-dynamic/src/compiler_reflector.ts#L55" rel="noopener noreferrer"&gt;variable.&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Incremental compilation &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The Angular 8 compilation pipeline started by &lt;code&gt;ng build prod --aot&lt;/code&gt; is composed of five phases where the &lt;code&gt;tsc&lt;/code&gt; and the &lt;code&gt;ngc&lt;/code&gt; generates the &lt;em&gt;template factories&lt;/em&gt;. &lt;code&gt;ngc&lt;/code&gt; compiles the libraries as well. Ivy enables &lt;em&gt;Incremental compilation&lt;/em&gt; that is libraries can be compiled and deployed on npm.&lt;/p&gt;
&lt;h3&gt;
  
  
  Locality &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Currently Angular relies on &lt;em&gt;global compilation&lt;/em&gt;. The compilation process requires a global static analysis of the entire application to combine different compilation outputs (application, libraries from the monorepo and libraries from npm) before emitting the bundle. Moreover, it is really complex to combine AOT libraries into a JIT application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
The compiler should use only information provided by component decorator and its class and nothing else. This simplifies the overall compilation process, no more &lt;code&gt;component.metadata.json&lt;/code&gt; and &lt;code&gt;component.ngfactory.json&lt;/code&gt; that requires complex management in the compilation pipeline.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Locality is a rule&lt;/em&gt;. Ivy compilation introduces the concept of &lt;em&gt;component/directive public API:&lt;/em&gt; an Angular application can &lt;em&gt;safely refer to components and directives public API&lt;/em&gt;, no more needed to know much about dependencies since &lt;em&gt;extra information&lt;/em&gt; are added to &lt;code&gt;.d.ts&lt;/code&gt; component files.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example: Ivy library compilation &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Add a library to the monorepo where your application is running &lt;code&gt;ng generate library mylib&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Compile the library with &lt;code&gt;ng build mylib&lt;/code&gt;, the following files are produced:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;├── bundles
├── ...
├── lib
│   ├── mylib.component.d.ts
│   ├── mylib.module.d.ts
│   └── mylib.service.d.ts
├── mylib.d.ts
├── package.json
└── public-api.d.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Notice as well that this new message is displayed in version 9 due to Ivy activation:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Building Angular Package
&lt;span class="k"&gt;******************************************************************************&lt;/span&gt;
It is not recommended to publish Ivy libraries to NPM repositories.
Read more here: https://next.angular.io/guide/ivy#maintaining-library-compatibility
&lt;span class="k"&gt;******************************************************************************&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h5&gt;
  
  
  Generated component
&lt;/h5&gt;

&lt;p&gt;This is the component generated by the Angular CLI:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;OnInit&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lib-mylib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;p&amp;gt;mylib works!&amp;lt;/p&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MylibComponent&lt;/span&gt; &lt;span class="kr"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;OnInit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;ngOnInit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h5&gt;
  
  
  Compiled library code
&lt;/h5&gt;

&lt;p&gt;The metadata file &lt;code&gt;mylib.metadata.json&lt;/code&gt; is not generated anymore, &lt;em&gt;metadata&lt;/em&gt; are now part of the &lt;em&gt;definition files&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Definition file of the component:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;OnInit&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;declare&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MylibComponent&lt;/span&gt; &lt;span class="kr"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;OnInit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nf"&gt;ngOnInit&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵfac&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵFactoryDef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibComponent&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵcmp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵComponentDefWithMeta&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lib-mylib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;never&lt;/span&gt;&lt;span class="p"&gt;,{},{},&lt;/span&gt;&lt;span class="nx"&gt;never&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Definition file of the module:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./mylib.component&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;declare&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MylibModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵmod&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵNgModuleDefWithMeta&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MylibComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;i1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MylibComponent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵinj&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵInjectorDef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibModule&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and the definition file of the service:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;declare&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MylibService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵfac&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵFactoryDef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibService&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵprov&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵInjectableDef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibService&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h5&gt;
  
  
  Add a property to the component
&lt;/h5&gt;

&lt;p&gt;Add to the library component an input field:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lib-mylib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;p&amp;gt;Please input your phone&amp;lt;/p&amp;gt;
    &amp;lt;input #phone placeholder="phone number" /&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MylibComponent&lt;/span&gt; &lt;span class="kr"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;OnInit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;phone-number&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;ngOnInit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The alias &lt;code&gt;phone-number&lt;/code&gt; will be added to the &lt;em&gt;input property&lt;/em&gt; providing additional metadata for the public API. The compiler generates the following definition file:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;OnInit&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;declare&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MylibComponent&lt;/span&gt; &lt;span class="kr"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;OnInit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nf"&gt;ngOnInit&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵfac&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵFactoryDef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibComponent&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;ɵcmp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ɵɵComponentDefWithMeta&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MylibComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lib-mylib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;phone&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;phone-number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;Decorator that marks a class field as an input property and supplies configuration metadata. The input property is bound to a DOM property in the template. During change detection, Angular automatically updates the data property with the DOM property's value.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Input decorator&lt;/cite&gt; - &lt;a href="https://angular.io/api/core/Input" rel="noopener noreferrer"&gt;Angular docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The property &lt;code&gt;phone-number&lt;/code&gt; is the name part of the public API while &lt;code&gt;phone&lt;/code&gt; is the private name, &lt;em&gt;an implementation detail&lt;/em&gt;. Since it can change, the code must be compiled every time to emit, in case, an error if there is a property name mismatch. For this reason, the current Angular version must rely on &lt;em&gt;global compilation&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Angular Ivy instead relies on the &lt;em&gt;public API&lt;/em&gt;, so library code can be compiled and safely shipped to npm.&lt;/p&gt;
&lt;h5&gt;
  
  
  Browser property
&lt;/h5&gt;

&lt;blockquote&gt;
&lt;p&gt;The input property is bound to a DOM property in the template.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When the browser loads the page, it “reads” (another word: “parses”) the HTML and generates DOM objects from it. For element nodes, most standard HTML attributes automatically become properties of DOM objects.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Attributes and properties&lt;/cite&gt; - &lt;a href="https://javascript.info/dom-attributes-and-properties" rel="noopener noreferrer"&gt;javascript.info&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The Angular compiler transforms the decorators and the templates into JavaScript instructions not only to create elements into the DOM but also &lt;em&gt;extra content properties and attributes&lt;/em&gt; used by the runtime to &lt;em&gt;"keep-alive"&lt;/em&gt; the application. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8xj080lma4eld18ddedy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8xj080lma4eld18ddedy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Flexibility &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Angular Ivy is more flexible than View Engine because if new &lt;em&gt;features&lt;/em&gt; are introduced in Angular new &lt;em&gt;instructions&lt;/em&gt; will be implemented in the set. Ivy is easier to be extended and optimized.&lt;/p&gt;
&lt;h2&gt;
  
  
  Angular Ivy Build Pipeline &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The compilation of an Angular application is just half of the process since the libraries the application depends on having to be made compatible with the &lt;em&gt;new runtime&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ngcc&lt;/code&gt; (Angular compatibility compiler) is a new compiler that convert and compile the libraries. Libraries compatible with &lt;code&gt;ViewEngine&lt;/code&gt;, the previous &lt;em&gt;rendering engine&lt;/em&gt; of Angular, are converted into Ivy instructions so that the &lt;em&gt;"library can participate in the Ivy runtime"&lt;/em&gt; and be fully compatible.&lt;/p&gt;

&lt;p&gt;The new compiler has been implemented to make libraries compatible with the new format without obliging maintainers to rewrite important parts of them and, moreover, not all the applications need to be compatible with Ivy.&lt;/p&gt;

&lt;p&gt;In Angular version 9 Ivy is enabled for application only and &lt;code&gt;ngcc&lt;/code&gt; is used to convert existing libraries making them Ivy compatible. Over time application will start to become more and more Ivy compatible and so the libraries, then &lt;code&gt;ngcc&lt;/code&gt; will not be any more necessary. Libraries can be converted &lt;em&gt;on the fly&lt;/em&gt; into Ivy compatible libraries during the &lt;em&gt;build or installation process&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The incremental transition from version 9 to version 11 will make &lt;code&gt;ngcc&lt;/code&gt; only required for some few cases:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Angular version&lt;/th&gt;
&lt;th&gt;ngcc&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;app on Ivy (opt-out) and libraries VE compatible&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;stabilize Ivy instruction set, libraries ship Ivy code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ngcc&lt;/code&gt; backup for obsolete libraries or not updated yet&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;ngcc-validation&lt;/code&gt; &lt;a href="https://github.com/angular/ngcc-validation" rel="noopener noreferrer"&gt;project&lt;/a&gt; is the way the Angular team tests the libraries' compatibility.&lt;/p&gt;
&lt;h2&gt;
  
  
  Component lazy loading feature &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Angular is an enabler, it will allow more improvement about performance not only for the build but also for the application. Since version 2 Angular has a &lt;em&gt;component lazy loading feature&lt;/em&gt; but just at &lt;em&gt;router level&lt;/em&gt;. Lazy loading at &lt;em&gt;component level&lt;/em&gt; requires a lot of boilerplate code and some patches to make it work.&lt;/p&gt;

&lt;p&gt;With Angular Ivy will be much simpler. Consider the following example: click on an image, lazy load the bundle and add the component to the view. &lt;em&gt;Lazy loading improves the speed of an application.&lt;/em&gt; &lt;em&gt;Ideally&lt;/em&gt; it will be:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppComponent&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;viewContainer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ViewContainer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;cfr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ComponentFactoryResolver&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// lazy click handler&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;lazyload&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// use the dynamic import&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;LazyComponent&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./lazy/lazy.component&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;viewContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LazyComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;View Engine obliges to pass via the &lt;code&gt;ComponentFactoryResolver&lt;/code&gt; to resolve the lazy component into a factory and to load it:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;viewContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cfr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolveComponentFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LazyComponent&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Bundle size  &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;To evaluate the bundle size improvement, the Angular team uses a &lt;em&gt;metric&lt;/em&gt;{: .italic-red-text} the &lt;em&gt;Hello World&lt;/em&gt; application. Building with Angular Ivy, the final minimized bundle is ~4.5kB and ~2.7kB with Closure Compiler.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Angular Elements&lt;/em&gt; can be then bundled more efficiently and, moreover, Ivy is ready for future bundlers/optimizers.&lt;/p&gt;
&lt;h2&gt;
  
  
  Debugging  &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;A new API has been added to the global &lt;code&gt;ng&lt;/code&gt; object. In the ChromeDevTools just open the console and type &lt;code&gt;ng&lt;/code&gt; to see the new options:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fekfp6ak1xeqg82yn7nte.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fekfp6ak1xeqg82yn7nte.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider to have a &lt;code&gt;&amp;lt;mat-drover&amp;gt;&amp;lt;/mat-drover&amp;gt;&lt;/code&gt; component from the Angular Material library, it is possible to directly act on the component from the console (thanks to Juri Strumpflohner for the example in &lt;a href="https://juristr.com/blog/2019/09/debugging-angular-ivy-console/" rel="noopener noreferrer"&gt;his tutorial&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// grab the component instance of the DOM element stored &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$0&lt;/span&gt;
&lt;span class="nb"&gt;let &lt;/span&gt;matDrawer &lt;span class="o"&gt;=&lt;/span&gt; ng.getComponent&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

// interact with the component&lt;span class="s1"&gt;'s API
matDrawer.toggle();

// trigger change detection on the component
ng.markDirty(matDrawer);
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;From the Elements tab just select the element of the debug action, a &lt;code&gt;$0&lt;/code&gt; will appear close to it, it can be used as selector/placeholder for the element in the console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzpet6yrrsj7skgwtt1gi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzpet6yrrsj7skgwtt1gi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NgProbe&lt;/code&gt; will not be probably supported anymore:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In Ivy, we don't support NgProbe because we have our own set of testing utilities with more robust functionality.&lt;/p&gt;

&lt;p&gt;We shouldn't bring in NgProbe because it prevents DebugNode and friends from tree-shaking properly.&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;Platform browser&lt;/cite&gt; - &lt;a href="https://github.com/angular/angular/blob/master/packages/platform-browser/src/dom/debug/ng_probe.ts#L40-L47" rel="noopener noreferrer"&gt;Angular source code&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Conclusions  &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Angular team has done an amazing job, it was really a pleasure to attend the Angular Connect 2019 and see the improvement done on the new rendering architecture introduced last year.&lt;/p&gt;

&lt;p&gt;Development can be done now with &lt;code&gt;aot&lt;/code&gt; compilation enabled by default to avoid possible mismatches between the development and the production environment.&lt;/p&gt;

&lt;p&gt;Another interesting point is the Angular Elements. I think the project can now really speeds up thanks to the new compiler and rendering engine. Currently, it is not possible to create a library project and compiler it as web components, this will really a killing feature. Moreover, the generated web components have &lt;em&gt;"too much Angular inside"&lt;/em&gt;, they are a bit too big, Ivy should reduce the amount of the framework that wraps an Angular component.&lt;/p&gt;

&lt;p&gt;Really impressive is the lazy loading that could be achieved in a very simple manner, powerful but keeping the readability of the code simple.&lt;/p&gt;
&lt;h2&gt;
  
  
  Special thanks
&lt;/h2&gt;

&lt;p&gt;Special thanks to &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__89994"&gt;
    &lt;a href="/layzee" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F89994%2F41ad1b6f-3d5a-4c73-894e-f7b0da8862c1.jpeg" alt="layzee image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/layzee"&gt;Lars Gyrup Brink Nielsen&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/layzee"&gt;👨‍🏫 Co-Founder of This is Learning, Organizer of AarhusJS
✍️ Writer, Speaker, FOSS Maintainer 📗 Author
🏆 Microsoft MVP 🌟 GitHub Star
🌊 Nx Champion 🦸 Angular Hero of Education&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;for the peer review and for having found some inaccuracies between Angular 8 and Angular 9 with Ivy enabled.&lt;/p&gt;

&lt;h2&gt;
  
  
  References  &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=6Zfk0OcFGn4&amp;amp;list=PLAw7NFdKKYpE-f-yMhP2WVmvTH2kBs00s" rel="noopener noreferrer"&gt;Angular Connect 2019 Keynote&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=anphffaCZrQ&amp;amp;list=PLAw7NFdKKYpE-f-yMhP2WVmvTH2kBs00s&amp;amp;index=2" rel="noopener noreferrer"&gt;Deep Dive into the Angular Compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.nrwl.io/understanding-angular-ivy-incremental-dom-and-virtual-dom-243be844bf36" rel="noopener noreferrer"&gt;Understanding Angular Ivy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://angular.io/guide/ivy" rel="noopener noreferrer"&gt;Opting into Angular Ivy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/angular-in-depth/a-deep-deep-deep-deep-deep-dive-into-the-angular-compiler-5379171ffb7a" rel="noopener noreferrer"&gt;A Deep, Deep, Deep, Deep, Deep Dive into the Angular Compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://indepth.dev/ivy-engine-in-angular-first-in-depth-look-at-compilation-runtime-and-change-detection/" rel="noopener noreferrer"&gt;Ivy engine in Angular&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://juristr.com/blog/2019/09/debugging-angular-ivy-console/" rel="noopener noreferrer"&gt;Debugging Angular Ivy Applications from the Devtools Console&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
