Angular 2/4 official starter build AOT deployment keynote.
After AOT compiling and Rollup bundling, my app size decreases from 3 MB to around 250 KB landing / 600~ KB total. Load-time improves noticeably.
Ahead-Of-Time Cookbook
I followed this guide and encountered some minor problems. Here’s some additional keynote:
- Make sure you update your project and global dependencies, if codes in a common library report error during compiling time, probably your TypeScript is too old.
- All config files in that guide have this file structure “src/app/***”, change it accounting to yours. Mine is “app/***”.
- If you’re using SystemJS in dev( way faster re-compiling ), and “moduleId: module.id” for templates relative URL. Put
<script>window.module = "Your App Name";</script>
in the very top of your index.html to avoid moduleId undefine error.
- In my rollup-config.js, I commented out:
if ( warning.indexOf("The 'this' keyword is equivalent to 'undefined'") > -1 ) { return; }
It keeps giving me trouble. Also, I changed the “plugins > commonjs > include” to include all of node_modules sub-folders for my other dependencies:
... commonjs({ include: 'node_modules/**' }), ...
Otherwise Rollup gets these errors: ” Error: ‘***’ is not exported by node_modules\*** “.