diff --git a/aio/content/guide/aot-compiler.md b/aio/content/guide/aot-compiler.md index 1a1e6a3889..64e892e3ea 100644 --- a/aio/content/guide/aot-compiler.md +++ b/aio/content/guide/aot-compiler.md @@ -42,7 +42,9 @@ Before the browser can render the application, the components and templates must be converted to executable JavaScript by the _Angular compiler_.
+ Watch compiler author Tobias Bosch explain the Angular Compiler at AngularConnect 2016. +
You can compile the app in the browser, at runtime, as the application loads, using the **_just-in-time_ (JIT) compiler**. @@ -161,10 +163,12 @@ Initiate AOT compilation from the command line using the previously installed `n
+ Windows users should surround the `ngc` command in double quotes: "node_modules/.bin/ngc" -p tsconfig-aot.json +
`ngc` expects the `-p` switch to point to a `tsconfig.json` file or a folder containing a `tsconfig.json` file. @@ -178,15 +182,19 @@ and a JavaScript representation of the component's template. Note that the original component class is still referenced internally by the generated factory.
+ The curious can open `aot/app.component.ngfactory.ts` to see the original Angular template syntax compiled to TypeScript, its intermediate form. JIT compilation generates these same _NgFactories_ in memory where they are largely invisible. AOT compilation reveals them as separate, physical files. +
+ Do not edit the _NgFactories_! Re-compilation replaces these files and all edits will be lost. +
{@a bootstrap} @@ -247,9 +255,11 @@ It produces a final code _bundle_ that excludes code that is exported, but never Rollup can only tree shake `ES2015` modules which have `import` and `export` statements.
+ Recall that `tsconfig-aot.json` is configured to produce `ES2015` modules. It's not important that the code itself be written with `ES2015` syntax such as `class` and `const`. What matters is that the code uses ES `import` and `export` statements rather than `require` statements. +
In the terminal window, install the Rollup dependencies with this command: @@ -304,8 +314,10 @@ Add the following to the `plugins` array:
+ In a production setting, you would also enable gzip on the web server to compress the code into an even smaller package going over the wire. +
{@a run-rollup} @@ -319,10 +331,12 @@ Execute the Rollup process with this command:
+ Windows users should surround the `rollup` command in double quotes: "node_modules/.bin/rollup" -c rollup-config.js +
{@a load} @@ -489,6 +503,7 @@ You'll need separate TypeScript configuration files such as these:
+
@Types and node modules
@@ -500,6 +515,7 @@ You'll need separate TypeScript configuration files such as these: In a more typical project, `node_modules` would be a sibling of `tsconfig-aot.json` and `"typeRoots"` would be set to `"node_modules/@types/"`. Edit your `tsconfig-aot.json` to fit your project's file structure. +
{@a shaking} @@ -516,6 +532,7 @@ Rollup does the tree shaking as before. ### Running the application
+ The general audience instructions for running the AOT build of the Tour of Heroes app are not ready. The following instructions presuppose that you have cloned the @@ -523,6 +540,7 @@ Rollup does the tree shaking as before. github repository and prepared it for development as explained in the repo's README.md. The _Tour of Heroes_ source code is in the `public/docs/_examples/toh-6/ts` folder. +
Run the JIT-compiled app with `npm start` as for all other JIT examples. @@ -549,7 +567,9 @@ Copy the AOT distribution files into the `/aot` folder with the node script:
+ You won't do that again until there are updates to `zone.js` or the `core-js` shim for old browsers. +
Now AOT-compile the app and launch it with the `lite-server`: