Skip to content

Commit 5fc1f24

Browse files
Alan Agiusalexeagle
authored andcommitted
feat(@angular-devkit/build-angular): deprecate es5BrowserSupport option in browser builder
In future, this will be determined from the list of supported browsers specified in the 'browserslist' file.
1 parent 86b23d7 commit 5fc1f24

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
debug,
1818
} from 'webpack';
1919
import { AssetPatternClass } from '../../../browser/schema';
20+
import { isEs5SupportNeeded } from '../../../utils/differential-loading';
2021
import { BundleBudgetPlugin } from '../../plugins/bundle-budget';
2122
import { CleanCssWebpackPlugin } from '../../plugins/cleancss-webpack-plugin';
2223
import { ScriptsWebpackPlugin } from '../../plugins/scripts-webpack-plugin';
@@ -66,20 +67,25 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
6667
}
6768

6869
const es5Polyfills = path.join(__dirname, '..', 'es5-polyfills.js');
69-
if (buildOptions.es5BrowserSupport) {
70-
entryPoints['polyfills.es5'] = [es5Polyfills];
71-
if (!buildOptions.aot) {
72-
entryPoints['polyfills.es5'].push(path.join(__dirname, '..', 'es5-jit-polyfills.js'));
73-
}
74-
}
70+
const es5JitPolyfills = path.join(__dirname, '..', 'es5-jit-polyfills.js');
7571

76-
if (buildOptions.es5BrowserSupport === undefined) {
72+
if (targetInFileName) {
73+
// For differential loading we don't need to have 2 polyfill bundles
7774
if (buildOptions.scriptTargetOverride === ts.ScriptTarget.ES2015) {
7875
entryPoints['polyfills'] = [path.join(__dirname, '..', 'safari-nomodule.js')];
7976
} else {
8077
entryPoints['polyfills'] = [es5Polyfills];
8178
if (!buildOptions.aot) {
82-
entryPoints['polyfills'].push(path.join(__dirname, '..', 'es5-jit-polyfills.js'));
79+
entryPoints['polyfills'].push(es5JitPolyfills);
80+
}
81+
}
82+
} else {
83+
// For NON differential loading we want to have 2 polyfill bundles
84+
if (buildOptions.es5BrowserSupport
85+
|| (buildOptions.es5BrowserSupport === undefined && isEs5SupportNeeded(projectRoot))) {
86+
entryPoints['polyfills.es5'] = [es5Polyfills];
87+
if (!buildOptions.aot) {
88+
entryPoints['polyfills.es5'].push(es5JitPolyfills);
8389
}
8490
}
8591
}

packages/angular_devkit/build_angular/src/browser/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308
"es5BrowserSupport": {
309309
"description": "Enables conditionally loaded ES2015 polyfills.",
310310
"type": "boolean",
311-
"default": false
311+
"x-deprecated": "This will be determined from the list of supported browsers specified in the 'browserslist' file."
312312
},
313313
"rebaseRootRelativeCssUrls": {
314314
"description": "Change root relative URLs in stylesheets to include base HREF and deploy URL. Use only for compatibility and transition. The behavior of this option is non-standard and will be removed in the next major release.",

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

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

99
export * from './default-progress';
1010
export * from './delete-output-dir';
11+
export * from './differential-loading';
1112
export * from './run-module-as-observable-fork';
1213
export * from './normalize-file-replacements';
1314
export * from './normalize-asset-patterns';

tests/legacy-cli/e2e/tests/misc/support-ie.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { oneLineTrim } from 'common-tags';
2-
import { expectFileNotToExist, expectFileToMatch } from '../../utils/fs';
2+
import { expectFileNotToExist, expectFileToMatch, writeFile } from '../../utils/fs';
33
import { ng } from '../../utils/process';
44
import { updateJsonFile } from '../../utils/project';
55

@@ -14,6 +14,7 @@ export default async function () {
1414
appArchitect.build.options.es5BrowserSupport = false;
1515
});
1616

17+
await writeFile('browserslist', 'last 2 Chrome versions');
1718
await ng('build');
1819
await expectFileNotToExist('dist/test-project/polyfills.es5.js');
1920
await expectFileToMatch('dist/test-project/index.html', oneLineTrim`
@@ -24,6 +25,7 @@ export default async function () {
2425
<script src="main.js"></script>
2526
`);
2627

28+
await writeFile('browserslist', 'IE 10');
2729
await ng('build', `--es5BrowserSupport`);
2830
await expectFileToMatch('dist/test-project/polyfills.es5.js', 'core-js');
2931
await expectFileToMatch('dist/test-project/index.html', oneLineTrim`

0 commit comments

Comments
 (0)