我在Angular 5应用程序中广泛使用了桶形概念 . 作为一个例子,在 core 模块中,我有一个 services 文件夹,可以像这样导出每个应用程序的模型(在index.ts文件中):
import { ApiService } from '@core/services/api.service';
export const services: Array<any> = [
ApiService
];
export * from '@core/services/api.service';
然后,我将这些模型传播到core.module中的providers键中:
import * as fromServices from '@core/services';
@NgModule({
declarations: [],
providers: [...fromServices.services],
exports: []
})
export class CoreModule {}
当我用纱线开始编译应用程序时,一切正常 . 但是,当我这样做
ng build --prod
我收到以下错误:
ERROR in:遇到未定义的提供商!通常这意味着你有一个循环依赖(可能是由于使用'桶'index.ts文件引起的 .
我的导入在_290873中如下命名:
{
"compilerOptions": {
"paths": {
"@core/*": ["app/core/*"],
}
}
}
任何帮助/提示将不胜感激 .
更新/解决方法#1:通过发出以下命令关闭AOT使得构建通过但没有AOT:ng build -prod -aot = false