Skip to content

Commit 7576136

Browse files
clydinfilipesilva
authored andcommitted
feat(@angular-devkit/build-angular): remove automatic inclusion of ES5 browser polyfills
BREAKING CHANGE: The automatic inclusion of Angular-required ES2015 polyfills to support ES5 browsers has been removed. Previously when targetting ES5 within the application's TypeScript configuration or listing an ES5 requiring browser in the browserslist file, Angular-required polyfills were included in the built application. However, with Angular no longer supporting IE11, there are now no browsers officially supported by Angular that would require these polyfills. As a result, the automatic inclusion of these ES2015 polyfills has been removed. Any polyfills manually added to an application's code are not affected by this change.
1 parent 5a46ff3 commit 7576136

File tree

14 files changed

+19
-243
lines changed

14 files changed

+19
-243
lines changed

packages/angular_devkit/build_angular/src/browser/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ export function buildWebpackBrowser(
231231
'scripts',
232232
).map((x) => x.bundleName);
233233

234-
const files = emittedFiles.filter((x) => x.name !== 'polyfills-es5');
235-
const noModuleFiles = emittedFiles.filter((x) => x.name === 'polyfills-es5');
236234
if (i18n.shouldInline) {
237235
const success = await i18nInlineEmittedFiles(
238236
context,
@@ -318,8 +316,8 @@ export function buildWebpackBrowser(
318316
// i18nLocale is used when Ivy is disabled
319317
lang: locale || undefined,
320318
outputPath,
321-
files: mapEmittedFilesToFileInfo(files),
322-
noModuleFiles: mapEmittedFilesToFileInfo(noModuleFiles),
319+
files: mapEmittedFilesToFileInfo(emittedFiles),
320+
noModuleFiles: [],
323321
moduleFiles: mapEmittedFilesToFileInfo(moduleFiles),
324322
});
325323

packages/angular_devkit/build_angular/src/dev-server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function serveWebpackBrowser(
315315
baseHref,
316316
entrypoints,
317317
moduleEntrypoints: [],
318-
noModuleEntrypoints: ['polyfills-es5'],
318+
noModuleEntrypoints: [],
319319
deployUrl: browserOptions.deployUrl,
320320
sri: browserOptions.subresourceIntegrity,
321321
postTransform: transforms.indexHtml,

packages/angular_devkit/build_angular/src/utils/build-browser-features.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import browserslist from 'browserslist';
1010
import { feature, features } from 'caniuse-lite';
11-
import * as ts from 'typescript';
1211

1312
export class BuildBrowserFeatures {
1413
readonly supportedBrowsers: string[];
@@ -17,13 +16,6 @@ export class BuildBrowserFeatures {
1716
this.supportedBrowsers = browserslist(undefined, { path: this.projectRoot });
1817
}
1918

20-
/**
21-
* True, when one or more browsers requires ES5 support
22-
*/
23-
isEs5SupportNeeded(): boolean {
24-
return !this.isFeatureSupported('es6-module');
25-
}
26-
2719
/**
2820
* True, when a browser feature is supported partially or fully.
2921
*/

packages/angular_devkit/build_angular/src/utils/package-chunk-sort.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function generateEntryPoints(appConfig: {
2828

2929
const entryPoints = [
3030
'runtime',
31-
'polyfills-es5',
3231
'polyfills',
3332
'sw-register',
3433
...extraEntryPoints(appConfig.styles, 'styles'),

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ import { Spinner } from '../../utils/spinner';
4646
import { addError } from '../../utils/webpack-diagnostics';
4747
import { DedupeModuleResolvePlugin, ScriptsWebpackPlugin } from '../plugins';
4848
import { JavaScriptOptimizerPlugin } from '../plugins/javascript-optimizer-plugin';
49-
import {
50-
getEsVersionForFileName,
51-
getOutputHashFormat,
52-
getWatchOptions,
53-
normalizeExtraEntryPoints,
54-
} from '../utils/helpers';
49+
import { getOutputHashFormat, getWatchOptions, normalizeExtraEntryPoints } from '../utils/helpers';
5550

5651
// eslint-disable-next-line max-lines-per-function
5752
export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
@@ -107,19 +102,6 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
107102
}
108103

109104
if (platform !== 'server') {
110-
if (buildBrowserFeatures.isEs5SupportNeeded()) {
111-
const polyfillsChunkName = 'polyfills-es5';
112-
entryPoints[polyfillsChunkName] = [path.join(__dirname, '..', 'es5-polyfills.js')];
113-
114-
if (!buildOptions.aot) {
115-
entryPoints[polyfillsChunkName].push(path.join(__dirname, '..', 'es5-jit-polyfills.js'));
116-
}
117-
118-
if (buildOptions.polyfills) {
119-
entryPoints[polyfillsChunkName].push(path.resolve(root, buildOptions.polyfills));
120-
}
121-
}
122-
123105
if (buildOptions.polyfills) {
124106
const projectPolyfills = path.resolve(root, buildOptions.polyfills);
125107
if (entryPoints['polyfills']) {
@@ -130,7 +112,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
130112
}
131113

132114
if (!buildOptions.aot) {
133-
const jitPolyfills = path.join(__dirname, '..', 'jit-polyfills.js');
115+
const jitPolyfills = 'core-js/proposals/reflect-metadata';
134116
if (entryPoints['polyfills']) {
135117
entryPoints['polyfills'].push(jitPolyfills);
136118
} else {
@@ -366,10 +348,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
366348
devtool: false,
367349
target: [
368350
platform === 'server' ? 'node' : 'web',
369-
tsConfig.options.target === ScriptTarget.ES5 ||
370-
(platform !== 'server' && buildBrowserFeatures.isEs5SupportNeeded())
371-
? 'es5'
372-
: 'es2015',
351+
tsConfig.options.target === ScriptTarget.ES5 ? 'es5' : 'es2015',
373352
],
374353
profile: buildOptions.statsJson,
375354
resolve: {
@@ -394,13 +373,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
394373
clean: buildOptions.deleteOutputPath ?? true,
395374
path: path.resolve(root, buildOptions.outputPath),
396375
publicPath: buildOptions.deployUrl ?? '',
397-
filename: ({ chunk }) => {
398-
if (chunk?.name === 'polyfills-es5') {
399-
return `polyfills-es5${hashFormat.chunk}.js`;
400-
} else {
401-
return `[name]${hashFormat.chunk}.js`;
402-
}
403-
},
376+
filename: `[name]${hashFormat.chunk}.js`,
404377
chunkFilename: `[name]${hashFormat.chunk}.js`,
405378
},
406379
watch: buildOptions.watch,

packages/angular_devkit/build_angular/src/webpack/es5-jit-polyfills.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/webpack/es5-polyfills.js

Lines changed: 0 additions & 116 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/webpack/jit-polyfills.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-context.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
%MAPPINGS%
3232
</script>
3333
<script src="_karma_webpack_/runtime.js" crossorigin="anonymous"></script>
34-
<script src="_karma_webpack_/polyfills-es5.js" crossorigin="anonymous" nomodule></script>
3534
<script src="_karma_webpack_/polyfills.js" crossorigin="anonymous"></script>
3635
<!-- Dynamically replaced with <script> tags -->
3736
%SCRIPTS%

packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-debug.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
%MAPPINGS%
3434
</script>
3535
<script src="_karma_webpack_/runtime.js" crossorigin="anonymous"></script>
36-
<script src="_karma_webpack_/polyfills-es5.js" crossorigin="anonymous" nomodule></script>
3736
<script src="_karma_webpack_/polyfills.js" crossorigin="anonymous"></script>
3837
<!-- Dynamically replaced with <script> tags -->
3938
%SCRIPTS%

0 commit comments

Comments
 (0)