Search code examples
angularangular-clijitangular2-aot

Angular 2 AOT vs JIT


I was just reading Angular 2 AOT documentation and a few questions poped up

  1. The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot

  2. The documentation goes through in detail about how to set it up. Would ng build --prod --aot be good enough to ignore all those setup?


Solution

    1. The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot

    AoT is the default for -prod as of beta 28.

    It's still NOT the default for dev build. Why? Because it takes longer time to compile and in dev you want fast feedback.

    Note that the current version of the Angular CLI at the time of writing is beta.29, and the package name has changed from angular-cli to @angular/cli.

    1. The documentation goes through in detail about how to set it up. Would ng build --prod --aot be good enough to ignore all those setup?

    Yes!

    And you can just ng build -prod if you are using the latest version of the CLI.