1

In Angular 5.1.0-beta.2 I'm having an error using: ng serve --aot

import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
import { AppComponent } from '../app.component';
import { DataModelService } from '@services/data-model.service';
import { BroadcasterService } from '@services/broadcaster.service';
import { GridManager } from '@services/grid.service';
import { ReactiveFormsModule } from '@angular/forms';
import { FormValidationService } from '@services/form-validation.service';
import { JitCompilerFactory } from "@angular/platform-browser-dynamic";
import { Compiler, COMPILER_OPTIONS, CompilerFactory, NgModule } from '@angular/core';


export function createCompiler(compilerFactory: CompilerFactory) {
  return compilerFactory.createCompiler();
}

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule, HttpClientModule, ReactiveFormsModule, HttpModule
  ],
  providers: [DataModelService, BroadcasterService, FormValidationService, GridManager,
    { provide: COMPILER_OPTIONS, useValue: {}, multi: true },
    { provide: CompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS] },
    { provide: Compiler, useFactory: createCompiler, deps: [CompilerFactory] }],
  bootstrap: [AppComponent]
})
export class AppModule { }

in another file where I call the compiler

   @Component({ template: myTemplate })
    class PhaseComponent implements OnInit { ngOnInit() {

      }
    }
    @NgModule({
      imports: [CommonModule, SharedModule],
      declarations: [PhaseComponent],
      schemas: [
        NO_ERRORS_SCHEMA
      ]
    })
    class TemplateModule {
    }

    const mod = this.compiler.compileModuleAndAllComponentsSync(TemplateModule);

My error is in the below image enter image description here

my setup

Angular CLI: 1.5.4
Node: 6.9.5
OS: win32 x64
Angular: 5.1.0-beta.2
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cli: 1.5.4
@angular/language-service: 5.0.3
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@schematics/angular: 0.1.7
typescript: 2.6.2
webpack: 3.8.1

Help me, please.

Vladu Ionut
  • 8,075
  • 1
  • 19
  • 30
  • Has this ever worked? It looks like you are trying to use ahead-of-time (AOT) compilation, but then compiling something in the code. Am I reading that right? – R. Richards Nov 29 '17 at 23:05
  • You are right. There are some recently closed issues ( https://github.com/angular/angular/issues/20639 ,https://github.com/angular/angular/issues/20125 ) with something similar – Vladu Ionut Nov 30 '17 at 07:41
  • I've updated to angular 5.1.0-rc.1, same issue – Vladu Ionut Dec 03 '17 at 23:32

0 Answers0