Search code examples
javascriptangularjitaot

Angular 2 rollup AoT build is bigger than normal JiT build


I have a problem with building my app. I want to make them weight less. Im using angular 2 seed as a base. https://github.com/mgechev/angular-seed

So after im running:

npm run build.prod 

my app.js is 1.5MB

after:

npm run build.prod.rollup.aot 

app.js is 1.9MB

and if I run only:

npm run build.prod.aot

it is 2.2Mb.

It is totally make no sense for me. Im not able to shere my app with you cause it is a private project. I would be greatfull if someone just have an idea what can be a cause of this.


Solution

  • Ahead of Time compilation has not been created to reduce code size. In some cases the compiled code is bigger, but anyway, the render time is drastically slower.

    If you want to reduce the first request downloaded total size, use lazy loading modules, but I think that's not the case.

    See for Lazy Loading: https://angular-2-training-book.rangle.io/handout/modules/lazy-loading-module.html

    See for Server Rendering: https://github.com/robwormald/ng-universal-demo/