Make it easyIf 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 limitsThere 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
typescriptversion, 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