1
聽到關於Angular AOT模式的太多內容後,我想給它一個嘗試。所以,我們將我們的應用程序遷移到了Angular v4.1.2,並進行了所有必需的更改。當我嘗試在我的webpack配置文件中使用ngc-webpack插件配置的以下部分運行AOT模式構建時,我陷入了一些未知錯誤。AOT清理加載程序錯誤,無法使用AOT模式構建Angular應用程序
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清潔-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)
我被困在這個錯誤現在已經相當一段時間,無法弄清楚什麼是我做的WRO的事NG。請有人幫我在這裏。
您正在使用哪種打字稿版本? – monica
當然,我意識到有人已經降級了打字稿版本,所以我將其升級到了2.2.2並且工作。 –