Easily AOT Angular Projects
by Stephen Fluin
AOT is perceived by many to be hard, but it doesn't have to be, if you are using the CLI.
Make it easy
If you use the Angular CLI, it's easy to turn AOT on for most Angular projects. At build time, simply:
ng build --aot --prod
You can also run this during development, but it's going to be slow.
ng serve --prod
This will generate a fully working version of your Angular application in your /dist/ folder. You won't ship the compiler and your application will boot faster than ever.
A couple limits
There are a couple limitations when doing AOT.
- All Component and Module metadata has to be statically resolvable - This means you can't do lookups or evaluate complex methods in your
- Double check your
typescript version, the CLI has trouble with some versions, try email@example.com
- Add any dynamically loaded components (aka Components never referenced by your router or templates) to your Module's