升级到Angular 8:在tsconfig.json中将目标更改为"es2015"导致polyfills-2015出错
Upgrade to Angular 8: Changing the target to "es2015" in tsconfig.json leads to error in polyfills-2015
将目标更改为 es2015(而不是 es5)时,启动我的应用程序时出现以下错误:
polyfills-es2015.4a168e5d0734802f67ed.js:1 Uncaught TypeError: Cannot set property 'true' of undefined
at Object.6dTf (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at Module.hN/g (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at Object.1 (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at t (runtime-es2015.05393c8efcd0eb158773.js:1)
at Array.r [as push] (runtime-es2015.05393c8efcd0eb158773.js:1)
at polyfills-es2015.4a168e5d0734802f67ed.js:1
此外,我需要在我的 main.ts 文件中 导入 Zone.js 而不是 polyfills.ts,否则我会收到错误消息:
in this configuration angular requires zone.js
我正在使用 Angular8、Typescript 3.4.5 和节点 12.4.0。我做错了什么?
我的tsconfig.json:
{
"angularCompilerOptions": {
"preserveWhitespaces": false
},
"compileOnSave": false,
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"compilerOptions": {
"outDir": "./dist/out-tsc/app",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"module": "esnext",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es6",
"dom"
],
"baseUrl": "./src"
}
}
问题来自 web-animations-js。
自 Angular6 起,不再需要:
We’ve updated our implementation of Animations to no longer need the
web animations polyfill. This means that you can remove this polyfill
from your application and save approximately 47KB of bundle size,
while increasing animations performance in Safari at the same time.
https://angular.io/guide/browser-support#enabling-polyfills
我从 polyfills 和我的 package.json 中删除了它,错误消失了。
将目标更改为 es2015(而不是 es5)时,启动我的应用程序时出现以下错误:
polyfills-es2015.4a168e5d0734802f67ed.js:1 Uncaught TypeError: Cannot set property 'true' of undefined
at Object.6dTf (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at Module.hN/g (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at Object.1 (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at t (runtime-es2015.05393c8efcd0eb158773.js:1)
at Array.r [as push] (runtime-es2015.05393c8efcd0eb158773.js:1)
at polyfills-es2015.4a168e5d0734802f67ed.js:1
此外,我需要在我的 main.ts 文件中 导入 Zone.js 而不是 polyfills.ts,否则我会收到错误消息:
in this configuration angular requires zone.js
我正在使用 Angular8、Typescript 3.4.5 和节点 12.4.0。我做错了什么?
我的tsconfig.json:
{
"angularCompilerOptions": {
"preserveWhitespaces": false
},
"compileOnSave": false,
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"compilerOptions": {
"outDir": "./dist/out-tsc/app",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"module": "esnext",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es6",
"dom"
],
"baseUrl": "./src"
}
}
问题来自 web-animations-js。
自 Angular6 起,不再需要:
We’ve updated our implementation of Animations to no longer need the web animations polyfill. This means that you can remove this polyfill from your application and save approximately 47KB of bundle size, while increasing animations performance in Safari at the same time.
https://angular.io/guide/browser-support#enabling-polyfills
我从 polyfills 和我的 package.json 中删除了它,错误消失了。