2017-08-05 68 views
0

My app与开发版本运行良好,但我没有让AOT生产构建工作。对于每一个懒加载的模块,我得到这样的错误:AOT与JHipster:module.ngfactory文件没有为懒惰加载模块生成

ERROR in ./target/aot/src/main/webapp/app/app.module.ngfactory.ts 
Module not found: Error: Can't resolve './features/about/about.module.ngfactory' in '/Users/Dan/work/a/gba/target/aot/src/main/webapp/app' 
@ ./target/aot/src/main/webapp/app/app.module.ngfactory.ts 535:190-240 
@ ./src/main/webapp/app/app.main-aot.ts 

,一个是这样的:

ERROR in ./src/main/webapp/app/app.routing.ts 
Module not found: Error: Can't resolve '../../../../target/aot/src/main/webapp/app/features/about/about.module.ngfactory' in '/Users/Dan/work/a/gba/src/main/webapp/app' 
@ ./src/main/webapp/app/app.routing.ts 15:137-228 
@ ./target/aot/src/main/webapp/app/app.module.ngfactory.ts 
@ ./src/main/webapp/app/app.main-aot.ts 

的路径似乎是正确的,但这些模块的文件不存在。如果我急切地加载一个懒惰的加载模块,那么该错误会消失。

我按照从angular-router-loader的方向。我觉得我做了正确的,但没有运气

// webpack.prod.js 
    { loader: 'angular-router-loader?aot=true&genDir=target/aot' } 


// tsconfig-aot.json 
"angularCompilerOptions": { 
    "genDir": "target/aot", 
    "skipMetadataEmit": true 
} 

回答

2

我怀疑你的问题与你的tsconfig-aot.json因为角度的编译器看起来你已经交给tsconfig文件有关。

因此,这里是我的假设:

tsconfig-aot.json

"files": [ 
    "src/main/webapp/app/app.module.ts", 
    "src/main/webapp/app/app.main-aot.ts", 
    "src/main/webpapp/app/features/about/about.module.ts" <= try to add this 
], 
+0

感谢。我相信编译器通过从app模块开始并遍历app.module - > app.routing - > about.module来获取about模块。不幸的是,将about.module添加到tsconfig并没有帮助。 –

+0

我如何重现它?我在您的回购中看不到有关模块 – yurzui

+0

此解决方案适用于我。我也使用'files'选项 – yurzui