我正在使用Angular4和.Net Core Mvc开发应用程序。
当我在package.json中运行dev bundle脚本时,它可以工作。脚本如下:
del-cli wwwroot/dist/js/app && webpack --config webpack.config.dev.js --progress --profile --watch
当我在package.json中运行prod bundle脚本时,它会给出以下错误:
app.module.ngfactory.ts ...'承诺'仅指类型,但在此处用作值
Prod脚本如下:
del-cli wwwroot/dist/js/app && ngc -p tsconfig.aot.json && ngc -p tsconfig.aot.json && webpack --config webpack.config.prod.js --progress --profile --bail && del-cli 'wwwroot/dist/js/app/**/*.js' 'wwwroot/dist/js/app/**/*.js.map' '!wwwroot/dist/js/app/bundle.js' '!wwwroot/dist/js/app/*.chunk.js' 'ClientApp/app/**/*.ngfactory.ts' 'ClientApp/app/**/*.shim.ts' 'ClientApp/app/**/*.ngsummary.json' 'ClientApp/app/**/*.ngstyle.ts'
我的tsconfig.aot.json文件如下:
"compilerOptions": {
"module": "es2015",
"target": "es5",
"lib": [
"es2015",
"dom"
],
"moduleResolution": "node",
"noImplicitAny": false,
"sourceMap": false,
"removeComments": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "./wwwroot/dist/js/app"
},
"types": [ "node", "lodash", "core-js" ],
"typeRoots": [
"node_modules/@types"
],
"angularCompilerOptions": {
"skipMetadataEmit": true
}
我无法处理错误,我尝试了很多东西。我尝试将es2016,es2017添加到tsconfig中的lib部分但是没有用。
package.json中的@ types / core-js版本也是0.9.39。
"@types/core-js": "^0.9.39",
"@types/lodash": "^4.14.59",
"@types/node": "^6.0.45",
"typescript": "^2.2.2"
你能帮助我吗?
提前致谢
答案 0 :(得分:0)
我想捆绑aot但正常的tsconfig文件会影响aot bundle。所以我准备了正常的tsconfig文件,如下所示,问题解决了:
{
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [ "es2016", "dom" ],
"moduleResolution": "node",
"noImplicitAny": false,
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"skipLibCheck": true
},
"exclude": [
"node_modules",
"wwwroot/dist/js"
]
}