Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 748
Nekor Avatar asked Dec 11 '25 02:12

Nekor


1 Answers

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/

like image 143
Serginho Avatar answered Dec 13 '25 17:12

Serginho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!