What are the different types of compilers used in Angular?

We utilize two distinct types of compilers in Angular:

  • Just-in-time (JIT) compiler
  • Ahead-of-time (AOT) compiler

Both compilers are valuable, but they serve quite different objectives. Because our browsers cannot comprehend TypeScript but only JavaScript, the JIT compiler is employed to convert TypeScript to JavaScript. This compilation phase is performed in a development environment, where less time is required for compilation and more time is required for development to swiftly iterate over features. When we use the ng serve or ng build commands to serve the app locally or produce an uncompressed build of the whole codebase, the JIT compiler is employed.

The AOT compiler, on the other hand, is used to generate a production-ready minified production build of the whole codebase. We must use the ng build command with the –prod blog option to utilize the AOT compiler: ng builds –prod. This tells the Angular CLI to generate a production-ready version of the codebase. This takes a little longer since various optimizations, such as minification, need time, but this time may be saved for production builds.