当我尝试构建我的 Angular 应用程序时,我得到以下作为 bundle 以及主文件和其他所需文件
0-es5.js
0-es2015.js
1-es5.js
1-es2015.js
4-es5.js
4-es2015.js
9-es5.js
9-es2015.js
10-es5.js
10-es2015.js
11-es5.js
11-es2015.js
12-es5.js
12-es2015.js
13-es5.js
13-es2015.js
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"resolveJsonModule": true,
"esModuleInterop": true
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
知道为什么会收到多个 es5 和 es2015 文件吗?
最佳答案
自 Angular 8 起,您将获得 ES2015 和 ES5 差异化的生产版本。根据应用程序加载的环境(即浏览器),其中之一会被加载 - 但不会同时加载两者。
此功能旨在为对 ES2015 没有良好支持的旧版本浏览器提供更好的兼容性,例如 Internet Explorer 或第一个 Edge 版本。
要禁用此功能,您可以阅读以下相关的SO问题:how to turn off differential loading in Angular v8?
关于javascript - Angular 9 - ng build --prod 创建了多个 es5 和 es2015 js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61388442/