Questions tagged [angular-aot]

A AOT-Compiler (Ahead of time) compiles the source code before the code is executed. Unlike the JIT-Compiler (Just in time) which compiles right when the code is executed.

The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code.

This guide explains how to build with the AOT compiler using different compiler options and how to write Angular metadata that AOT can compile.

To find more information :

176 questions
2
votes
1 answer

Is there a way to include the JIT compiler with an AOT angular 6/7 build?

I need to the ability to dynamically create modules and components ( with different templates) during runtime with a production build (aot enabled). I know this is possible with dev builds where the JIT compiler is used. But i don't want this for my…
kugar
  • 129
  • 1
  • 1
  • 6
2
votes
0 answers

Passing environment variables to custom library with forRoot()

I am trying to pass environment specific variables to my own library. And I'm passing it through forRoot(). For hard-coded values i am able to pass it but for environment values when i pass it to the library, it shows as undefined. const rootUrl =…
2
votes
1 answer

How to provide service inside the component in angular 5 with aot?

I have met the error question-images.service.ts(5,2): Error during template compile of 'QuestionImagesService' Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the…
Nikita
  • 1,019
  • 2
  • 15
  • 39
2
votes
2 answers

angular ng build --prod doesn't ignore unused/unimported components

I have a couple of components which are part of a template which I dont use but don't what to physically delete. I have commented out every import statement and reference to the component class but I'm still getting the error when running ng build…
Han Che
  • 8,239
  • 19
  • 70
  • 116
2
votes
0 answers

error:`runtime compiler is not loaded` in aot mode

In my angular 6 project I want to define all routes of DashboardModule as a children of profile route in AppModule like below code RouterModule.forRoot([ { path: '', component: HomeComponent }, { path: 'profile', loadChildren:…
Ravi Sevta
  • 2,817
  • 21
  • 37
2
votes
0 answers

How to attach a [formControl] to an type when instantiating it in Angular

I am trying to attach a [formControl] (and other top level attributes) to an object that I create with a ComponentFactoryResolver in order to handle the form logic with a ControlValueAccessor. Basically I do this: @Component({selector:…
jsgoupil
  • 3,788
  • 3
  • 38
  • 53
2
votes
1 answer

Do unused modules exported by SharedModule affect performance in an Angular app?

I have a Material module that contains imports/exports for Angular Material components. import { NgModule } from '@angular/core'; import { MdToolbarModule, MdIconModule, MdSidenavModule, } from '@angular/material'; @NgModule({ imports: [ …
jeanl
  • 379
  • 2
  • 7
  • 18
2
votes
1 answer

angular5 dynamic component resolver

I have multiple modules, each containing various components, and a parent component that needs to contain one of these components. Since I cannot use routes to achieve this, I authored a service that given a moduleName :string and a compomnentName :…
Cec
  • 1,726
  • 3
  • 18
  • 31
2
votes
1 answer

How to define a variable in external config file and use it in app.module

In Ionic 3 with Angular 5 I am trying to define all my external API keys inside an app.config.ts file. I must declare a class otherwise I get an AOT error raised by ngc. Here is my app.config.ts import { Injectable } from…
Manuel RODRIGUEZ
  • 2,131
  • 3
  • 25
  • 53
2
votes
1 answer

Angular AOT unknown identifier undefined

I'm trying to run AOT compilation on my Angular project but when I run the command "./node_modules/.bin/ngc" -p tsconfig-aot.json I got the following error: Error: Internal error: unknown identifier undefined at Object.importExpr$$1 [as…
2
votes
0 answers

Using AoT pre-compiled component factories for JiT compilation

I have a random markups from back-end that should be compiled in runtime with JiT. Every component used in this markups is already pre-compiled with AoT (added to entryComponents block) and so has component factory in runtime. When JiT compiles…
drow
  • 194
  • 3
  • 15
2
votes
1 answer

Angular - AOT Compilation ng vs ngc

What is different between AOT with ngc and rollup ngc -p tsconfig-aot.json && rollup -c rollup-config.js https://angular.io/guide/aot-compiler#aot-quickstart-source-code and AOT with Angular CLI ng build…
Jongz Puangput
  • 5,527
  • 10
  • 58
  • 96
2
votes
0 answers

Angular 2/4 Cli Ahead of Time Compilation error

I am trying to build a production version of my angular web application. The command that I am using is: ng build --prod It is my understanding that this will build a version of the application using aot. However when I try the above command I am…
Dblock247
  • 6,167
  • 10
  • 44
  • 66
2
votes
1 answer

Angular4 AOT with Semantic Less not working

I have a strange issue when using angular4 with semantic less (and semantic for angular2 from vladotesanovic). When I'm launching my project (npm start) everything works fine. But when I'm launching with AOT compilation (npm run build:aot -> num run…
Anton Lee
  • 684
  • 4
  • 10
2
votes
2 answers

How can I initiate watch mode with ngc?

I would like to do the same, as I could in the good old tsc times: simply calling a tsc -w, and in the case of a changed file, it will be on the fly recompilated. Unfortunately, ngc doesn't even seem to react anything to the -w flag, and even its…
peterh
  • 11,875
  • 18
  • 85
  • 108