在听到有关Angular AOT模式的太多之后,我想尝试一下。因此,我们将应用程序迁移到Angular v4.1.2,并具有所需的所有必要更改。当我尝试使用AOT模式运行构建时,在WebPack配置文件中使用NGC-WEBPACK插件的以下部分运行构建时,我陷入了一些未知错误。
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%的完成后运行构建,并使用Awesome Typescript加载器编译,AOT-CLEAN-COPMILES起作用并抛出了下面的大堆栈,如下所示: -
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,它不应为此版本丢弃此错误。