繁体   English   中英

AOT清理加载程序中的错误,无法以AOT模式构建Angular App

[英]Error in AOT cleanup loader, failed to build Angular App with AOT mode

在听到了很多有关Angular AOT模式的信息之后,我想尝试一下。 因此,我们将应用程序迁移到了Angular v4.1.2,并进行了所有必要的更改。 当我尝试在Webpack配置文件中使用ngc-webpack插件配置的以下部分以AOT模式运行构建时,我陷入了一些未知错误。

new ngcWebpack.NgcWebpackPlugin({
        disabled: !AOT,
        tsConfig: helpers.root('tsconfig.webpack.json')
      }),

我的tsconfig.webpack.json文件如下:-

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    some ts configs
    ....
    ....
     ...
    "lib": [
      "dom",
      "es2015"
    ],
    "baseUrl": ".",
    "paths": {
      "@angular/*": ["node_modules/@angular/*"]
    },

    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "hammerjs",
      "node",
      "jasmine",
      "lodash",
      "source-map",
      "uglify-js",
      "webpack"
    ]
  },
  "exclude": [
    "node_modules",
    "dist",
    "src/**/*.spec.ts",
    "src/**/*.e2e.ts"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "angularCompilerOptions": {
    "genDir": "./compiled",
    "skipMetadataEmit": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

当我运行构建时,在完成94%的工作后,并使用令人敬畏的打字机加载器成功编译后,aot-clean-compiles起作用并抛出如下所示的大堆栈跟踪信息:-

ERROR in ./src/app/applications/xxx.component.ts
Module build failed: TypeError: refactor.program.getTypeChecker(...).getTypeFromTypeNode is not a function
    at _ctorParameterFromTypeReference (/Users/xxx/sources/migration/yyy/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:57:58)
    at /Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:123:12
    at Array.map (native)
    at _addCtorParameters (/Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:122:46)
    at /Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:154:11
    at Array.forEach (native)
    at _removeDecorators (/Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:147:6)
    at Object.aotCleanLoader (/Users/xxx/sources/migration/bm_dashbaord/node_modules/src/aot-clean-transformer/loader/text-based-loader/loader.ts:303:7)

我在这个错误上停留了相当长的时间,无法弄清楚我在做什么错。 请有人在这里帮我。

您可以检查版本是否为2.2.2,对于该版本,不应引发此错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM