본문 바로가기

Frontend/Angular

AOT (Ahead Of Time) Compiler

반응형

Compiling Steps

Code analysis Code generation Template type checking
Creates a source sample but does not start compiling. Only records the syntax errors of the metadata Keeps analyzing the syntax errors of the metadata and shows the errors Checks the syntax of the binding in templates (Optional phase)

To turn on the template type-checking option, add the following code in the angularCompilerOptions of the 'tsconfig.json'

"strictInjectionParameters": true
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    // ...
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true, // Turns on the option
    // ...
  }
}

Source Code: https://angular.io/guide/angular-compiler-options


How does it work

Code analysis

In this stage, the TypeScript compiler will analyze the code and creates '.d.ts' that stores the type information (the AOT compiler uses this to create an application code). AOT compiler creates '.d.ts' for each '.metadata.json' file using the data inside the decorators

Code generation

In this stage, the compiler checks any syntax error in the metadata. The collector accepts only those functions and static methods with one return value


References

 

Angular

 

angular.io

 

728x90
반응형

'Frontend > Angular' 카테고리의 다른 글

Angular Library - Angular Router  (0) 2023.03.30
Angular Library  (1) 2023.03.30
Angular(Compiler) - JIT VS AOT  (1) 2023.03.21
Angular - Project Structure  (0) 2023.03.21
Angular - CLI  (0) 2023.03.21