【问题标题】:AOT with JHipster: module.ngfactory files not being generated for lazy loaded modules带有 JHipster 的 AOT:没有为延迟加载的模块生成 module.ngfactory 文件
【发布时间】:2018-01-13 12:47:10
【问题描述】:

My app 在开发版本中运行良好,但我没有让 AOT 生产版本正常工作。对于每个延迟加载的模块,我都会收到如下错误:

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
}

【问题讨论】:

    标签: angular webpack jhipster


    【解决方案1】:

    我怀疑您的问题与您的 tsconfig-aot.json 有关,因为 Angular 的编译器会查看您交给 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
    ],
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-16
    • 2017-05-16
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 2019-09-27
    • 2018-12-29
    • 2017-04-04
    相关资源
    最近更新 更多