Angular 2, @ngtools/webpack, AOT

被刻印的时光 ゝ 提交于 2019-12-06 09:48:50

I don't really know if it helps, but I had similar problem. I'm guessing you are using some kind of boilerplate because you have this helpers.root function.

First of all try to change this part:

new AotPlugin({
    tsConfigPath: 'tsconfig.json',
    entryModule: helpers.root('src/app/app.module.ts#AppModule')
})

to this (adding helpers.root part to tsconfig.json file):

new AotPlugin({
    tsConfigPath: helpers.root('tsconfig.json'),
    entryModule: helpers.root('src/app/app.module.ts#AppModule')
})

Second of all double check your tsconfig.json to be configured to AoT compilation. This is my tsconfig-aot.json which I',m using in one of my Angular 2 projects:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es2015", "dom"],
    "noImplicitAny": false,
    "sourceRoot": ".",
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "node_modules/@types"
    ]
  },

  "awesomeTypescriptLoaderOptions": {
    "useWebpackText": true,
    "forkChecker": true,
    "useCache": true
  },

  "angularCompilerOptions": {
    "genDir": "aot",
    "skipMetadataEmit" : true
  }
}

Hope this will help!

Try rolling back to ngtools/webpack version 1.2.4 there are issues with the path resolution in later versions related to this issue 5329.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!