web-dev-qa-db-ja.com

_lazy_route_resource遅延名前空間オブジェクト

angularコンパイラを使用しています:const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin;

これらのコンパイラオプションを使用する場合:

"angularCompilerOptions": {
"genDir": "./build/compiled",
"outDir": "./build/compiled",
"skipMetadataEmit": true,
"debug": true},

私のpackage.jsonの関連部分は:

"@ngtools/webpack": "^6.0.0",
"@angular/router": "^5.2.0",
"webpack": "4.8.3",
"webpack-cli": "2.1.4",

そして、私のangularCompilerPlugin設定は:

new AngularCompilerPlugin({
  tsConfigPath: 'path-to-tsconfig.webpack.json',
  entryModule: 'path-to-app.module#AppModule',
  sourceMap: true
}),

これらの構成で、私は得ています:

ERROR in ./$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve 'path-/alerts/module.ngfactory.js' in 'path-to-app-folder/$$_lazy_route_resource'
 @ ./$$_lazy_route_resource lazy namespace object
 @ ./node_modules/@angular/core/esm5/core.js
 @ multi core-js/shim classlist.js reflect-metadata zone.js/dist/zone jquery/dist/jquery rxjs/Rx lodash jquery.panzoom moment moment-timezone @angular/common @angular/core @angular/http @angular/router @angular/forms semantic

指示や助けをお願いします。

10
Usman Aziz

filesセクションのts.config-aot.jsonにレイジーモジュールの.tsパスを追加することで、このエラーを解決できました。

{
    "compilerOptions": {
        "target": "es5", //most browsers currently understand this version of Javascript
        "experimentalDecorators": true, //Angular2 uses Component,Injectable etc
        "emitDecoratorMetadata": true, //Required for Angular2 to use the metadata in our components
        //"sourceMap": true
        "types": [
            "node",
            "jasmine"
        ],
        // "typeRoots": [
        //     "node_modules/@types"
        // ],
        "lib": [
            "es2015",
            "es2015.iterable",
            "dom"
        ]
    },
    "exclude": [
        "node_modules"
    ],
    "files": [
        "src/app/app.module.ts",
        "src/main.ts",
        "src/app.d.ts",
        "src/app/sandbox/sandbox.module.ts",
        "src/app/supplier-xchange/supplier-xchange.module.ts",
        "src/app/company-profile/company-profile.module.ts",
        "src/app/bom/bom.module.ts",
        "src/app/custom-price-column/custom-price-column.module.ts",
        "src/app/neca/neca.module.ts"
    ]
}
2
Brian Ogden