Angular ng build -p AoT 问题
Angular ng build -p AoT issue
我在项目中执行命令 ng build -prod 时遇到问题,实际上我花了很多时间阅读控制台中显示的错误:
ERROR in Error: Error encountered resolving symbol values statically.
Calling function 'RequesthuellaModule', function calls are not
supported. Consider replacing the function or lambda with a reference
to an exported function, resolving symbol TallerModule in
/Users/mac/generator/boilerplate-webangular2/src/app/modules/taller/taller.module.ts,
resolving symbol TallerModule in
/Users/mac/generator/boilerplate-webangular2/src/app/modules/taller/taller.module.ts
我发现的所有答案都告诉我使用了一些 lambda 函数,但我的代码中没有。我把我使用的文件的来源:
图书馆requesthuella.module.ts
import { NgModule, ModuleWithProviders } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HuellaService } from './../serviceS/huella.service';
import { RequestHuellaOpciones } from './../models/RequestHuellaOpciones';
import { RequestHuellaComponent } from './requesthuella.component';
@NgModule({
declarations: [
// Pipes.
// Directives.
],
exports: [
// Pipes.
// Directives.
],
imports: [
FormsModule
]
})
export class RequesthuellaModule {
public static forRoot(): ModuleWithProviders {
return {
ngModule: RequesthuellaModule,
providers: [HuellaService, RequestHuellaComponent]
};
}
public static forChild(): ModuleWithProviders {
return {
ngModule: RequesthuellaModule,
providers: [HuellaService, RequestHuellaComponent]
};
}
}
taller.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule} from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import { OrderModule } from 'ngx-order-pipe';
import {NgxPaginationModule} from 'ngx-pagination';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { BlockUIModule } from 'ng-block-ui';
import { ModalModule } from 'ngx-bootstrap';
import { DirectivesModule} from 'app/directives/directives.module';
import {DataTableModule} from 'angular2-datatable';
import { RequesthuellaModule, HuellaService, RequestHuellaComponent } from '@oc/requesthuella-library';
import { TallerRoutingModule } from './taller-routing.module';
import { TallerComponent } from './taller.component';
import { TallerFormComponent } from './taller-form.component';
import { CentrosService } from './services/centros.service';
import { TallerModalComponent } from './modals/taller-modal/taller-modal.component';
@NgModule({
imports: [
CommonModule,
TallerRoutingModule,
FormsModule,
ReactiveFormsModule,
OrderModule,
NgxPaginationModule,
TooltipModule.forRoot(),
BlockUIModule,
ModalModule.forRoot(),
DirectivesModule,
DataTableModule,
RequesthuellaModule.forRoot()
],
declarations: [TallerComponent, TallerFormComponent, TallerModalComponent, RequestHuellaComponent],
providers: [
CentrosService,
HuellaService
],
entryComponents: [TallerModalComponent],
})
export class TallerModule { }
我不知道为什么会出现错误,顺便说一句,如果我只使用 ng build 构建它,它就像一个魅力,只有在添加 -prod 参数时才会导致问题。
感谢阅读。
我发现了问题所在。用于库脚手架的 templete 版本我只是更新它并配置文件 tsconfig.ts.
代码是正确的,只是过时的依赖和错误的配置。
我在项目中执行命令 ng build -prod 时遇到问题,实际上我花了很多时间阅读控制台中显示的错误:
ERROR in Error: Error encountered resolving symbol values statically. Calling function 'RequesthuellaModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol TallerModule in /Users/mac/generator/boilerplate-webangular2/src/app/modules/taller/taller.module.ts, resolving symbol TallerModule in /Users/mac/generator/boilerplate-webangular2/src/app/modules/taller/taller.module.ts
我发现的所有答案都告诉我使用了一些 lambda 函数,但我的代码中没有。我把我使用的文件的来源:
图书馆requesthuella.module.ts
import { NgModule, ModuleWithProviders } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HuellaService } from './../serviceS/huella.service';
import { RequestHuellaOpciones } from './../models/RequestHuellaOpciones';
import { RequestHuellaComponent } from './requesthuella.component';
@NgModule({
declarations: [
// Pipes.
// Directives.
],
exports: [
// Pipes.
// Directives.
],
imports: [
FormsModule
]
})
export class RequesthuellaModule {
public static forRoot(): ModuleWithProviders {
return {
ngModule: RequesthuellaModule,
providers: [HuellaService, RequestHuellaComponent]
};
}
public static forChild(): ModuleWithProviders {
return {
ngModule: RequesthuellaModule,
providers: [HuellaService, RequestHuellaComponent]
};
}
}
taller.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule} from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import { OrderModule } from 'ngx-order-pipe';
import {NgxPaginationModule} from 'ngx-pagination';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { BlockUIModule } from 'ng-block-ui';
import { ModalModule } from 'ngx-bootstrap';
import { DirectivesModule} from 'app/directives/directives.module';
import {DataTableModule} from 'angular2-datatable';
import { RequesthuellaModule, HuellaService, RequestHuellaComponent } from '@oc/requesthuella-library';
import { TallerRoutingModule } from './taller-routing.module';
import { TallerComponent } from './taller.component';
import { TallerFormComponent } from './taller-form.component';
import { CentrosService } from './services/centros.service';
import { TallerModalComponent } from './modals/taller-modal/taller-modal.component';
@NgModule({
imports: [
CommonModule,
TallerRoutingModule,
FormsModule,
ReactiveFormsModule,
OrderModule,
NgxPaginationModule,
TooltipModule.forRoot(),
BlockUIModule,
ModalModule.forRoot(),
DirectivesModule,
DataTableModule,
RequesthuellaModule.forRoot()
],
declarations: [TallerComponent, TallerFormComponent, TallerModalComponent, RequestHuellaComponent],
providers: [
CentrosService,
HuellaService
],
entryComponents: [TallerModalComponent],
})
export class TallerModule { }
我不知道为什么会出现错误,顺便说一句,如果我只使用 ng build 构建它,它就像一个魅力,只有在添加 -prod 参数时才会导致问题。
感谢阅读。
我发现了问题所在。用于库脚手架的 templete 版本我只是更新它并配置文件 tsconfig.ts.
代码是正确的,只是过时的依赖和错误的配置。