At a distant space view post, we chat about codes.

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:

  1. 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.
  2. All config files in that guide have this file structure “src/app/***”,  change it accounting to yours. Mine is “app/***”.
  3. If you’re using SystemJS in dev( way faster re-compiling ), and  “moduleId:” 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.

  4. 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:

            include: 'node_modules/**'

    Otherwise Rollup gets these errors: ” Error: ‘***’ is not exported by node_modules\*** “.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Angular 2/4 official starter build AOT deployment keynote.