diff --git a/packages/angular_devkit/build_angular/src/browser/index.ts b/packages/angular_devkit/build_angular/src/browser/index.ts index 3374e9a52264..97ed7b694cac 100644 --- a/packages/angular_devkit/build_angular/src/browser/index.ts +++ b/packages/angular_devkit/build_angular/src/browser/index.ts @@ -231,8 +231,6 @@ export function buildWebpackBrowser( 'scripts', ).map((x) => x.bundleName); - const files = emittedFiles.filter((x) => x.name !== 'polyfills-es5'); - const noModuleFiles = emittedFiles.filter((x) => x.name === 'polyfills-es5'); if (i18n.shouldInline) { const success = await i18nInlineEmittedFiles( context, @@ -318,8 +316,8 @@ export function buildWebpackBrowser( // i18nLocale is used when Ivy is disabled lang: locale || undefined, outputPath, - files: mapEmittedFilesToFileInfo(files), - noModuleFiles: mapEmittedFilesToFileInfo(noModuleFiles), + files: mapEmittedFilesToFileInfo(emittedFiles), + noModuleFiles: [], moduleFiles: mapEmittedFilesToFileInfo(moduleFiles), }); diff --git a/packages/angular_devkit/build_angular/src/dev-server/index.ts b/packages/angular_devkit/build_angular/src/dev-server/index.ts index e39d63cdaade..645c518220a3 100644 --- a/packages/angular_devkit/build_angular/src/dev-server/index.ts +++ b/packages/angular_devkit/build_angular/src/dev-server/index.ts @@ -315,7 +315,7 @@ export function serveWebpackBrowser( baseHref, entrypoints, moduleEntrypoints: [], - noModuleEntrypoints: ['polyfills-es5'], + noModuleEntrypoints: [], deployUrl: browserOptions.deployUrl, sri: browserOptions.subresourceIntegrity, postTransform: transforms.indexHtml, diff --git a/packages/angular_devkit/build_angular/src/utils/build-browser-features.ts b/packages/angular_devkit/build_angular/src/utils/build-browser-features.ts index 958dca8e47b3..8a06094d6988 100644 --- a/packages/angular_devkit/build_angular/src/utils/build-browser-features.ts +++ b/packages/angular_devkit/build_angular/src/utils/build-browser-features.ts @@ -8,7 +8,6 @@ import browserslist from 'browserslist'; import { feature, features } from 'caniuse-lite'; -import * as ts from 'typescript'; export class BuildBrowserFeatures { readonly supportedBrowsers: string[]; @@ -17,13 +16,6 @@ export class BuildBrowserFeatures { this.supportedBrowsers = browserslist(undefined, { path: this.projectRoot }); } - /** - * True, when one or more browsers requires ES5 support - */ - isEs5SupportNeeded(): boolean { - return !this.isFeatureSupported('es6-module'); - } - /** * True, when a browser feature is supported partially or fully. */ diff --git a/packages/angular_devkit/build_angular/src/utils/package-chunk-sort.ts b/packages/angular_devkit/build_angular/src/utils/package-chunk-sort.ts index a0665b69b01a..2220bf285d08 100644 --- a/packages/angular_devkit/build_angular/src/utils/package-chunk-sort.ts +++ b/packages/angular_devkit/build_angular/src/utils/package-chunk-sort.ts @@ -28,7 +28,6 @@ export function generateEntryPoints(appConfig: { const entryPoints = [ 'runtime', - 'polyfills-es5', 'polyfills', 'sw-register', ...extraEntryPoints(appConfig.styles, 'styles'), diff --git a/packages/angular_devkit/build_angular/src/webpack/configs/common.ts b/packages/angular_devkit/build_angular/src/webpack/configs/common.ts index 1894f37a5bd2..4d9ecbff147a 100644 --- a/packages/angular_devkit/build_angular/src/webpack/configs/common.ts +++ b/packages/angular_devkit/build_angular/src/webpack/configs/common.ts @@ -46,12 +46,7 @@ import { Spinner } from '../../utils/spinner'; import { addError } from '../../utils/webpack-diagnostics'; import { DedupeModuleResolvePlugin, ScriptsWebpackPlugin } from '../plugins'; import { JavaScriptOptimizerPlugin } from '../plugins/javascript-optimizer-plugin'; -import { - getEsVersionForFileName, - getOutputHashFormat, - getWatchOptions, - normalizeExtraEntryPoints, -} from '../utils/helpers'; +import { getOutputHashFormat, getWatchOptions, normalizeExtraEntryPoints } from '../utils/helpers'; // eslint-disable-next-line max-lines-per-function export function getCommonConfig(wco: WebpackConfigOptions): Configuration { @@ -107,19 +102,6 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { } if (platform !== 'server') { - if (buildBrowserFeatures.isEs5SupportNeeded()) { - const polyfillsChunkName = 'polyfills-es5'; - entryPoints[polyfillsChunkName] = [path.join(__dirname, '..', 'es5-polyfills.js')]; - - if (!buildOptions.aot) { - entryPoints[polyfillsChunkName].push(path.join(__dirname, '..', 'es5-jit-polyfills.js')); - } - - if (buildOptions.polyfills) { - entryPoints[polyfillsChunkName].push(path.resolve(root, buildOptions.polyfills)); - } - } - if (buildOptions.polyfills) { const projectPolyfills = path.resolve(root, buildOptions.polyfills); if (entryPoints['polyfills']) { @@ -130,7 +112,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { } if (!buildOptions.aot) { - const jitPolyfills = path.join(__dirname, '..', 'jit-polyfills.js'); + const jitPolyfills = 'core-js/proposals/reflect-metadata'; if (entryPoints['polyfills']) { entryPoints['polyfills'].push(jitPolyfills); } else { @@ -366,10 +348,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { devtool: false, target: [ platform === 'server' ? 'node' : 'web', - tsConfig.options.target === ScriptTarget.ES5 || - (platform !== 'server' && buildBrowserFeatures.isEs5SupportNeeded()) - ? 'es5' - : 'es2015', + tsConfig.options.target === ScriptTarget.ES5 ? 'es5' : 'es2015', ], profile: buildOptions.statsJson, resolve: { @@ -394,13 +373,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { clean: buildOptions.deleteOutputPath ?? true, path: path.resolve(root, buildOptions.outputPath), publicPath: buildOptions.deployUrl ?? '', - filename: ({ chunk }) => { - if (chunk?.name === 'polyfills-es5') { - return `polyfills-es5${hashFormat.chunk}.js`; - } else { - return `[name]${hashFormat.chunk}.js`; - } - }, + filename: `[name]${hashFormat.chunk}.js`, chunkFilename: `[name]${hashFormat.chunk}.js`, }, watch: buildOptions.watch, diff --git a/packages/angular_devkit/build_angular/src/webpack/es5-jit-polyfills.js b/packages/angular_devkit/build_angular/src/webpack/es5-jit-polyfills.js deleted file mode 100644 index 43d7cc718aed..000000000000 --- a/packages/angular_devkit/build_angular/src/webpack/es5-jit-polyfills.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import 'core-js/es/reflect'; diff --git a/packages/angular_devkit/build_angular/src/webpack/es5-polyfills.js b/packages/angular_devkit/build_angular/src/webpack/es5-polyfills.js deleted file mode 100644 index 5b57b1e86960..000000000000 --- a/packages/angular_devkit/build_angular/src/webpack/es5-polyfills.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -// ES2015 symbol capabilities -import 'core-js/es/symbol'; - -// ES2015 function capabilities -import 'core-js/modules/es.function.bind'; -import 'core-js/modules/es.function.name'; -import 'core-js/modules/es.function.has-instance'; - -// ES2015 object capabilities -import 'core-js/modules/es.object.create'; -import 'core-js/modules/es.object.define-property'; -import 'core-js/modules/es.object.define-properties'; -import 'core-js/modules/es.object.get-own-property-descriptor'; -import 'core-js/modules/es.object.get-prototype-of'; -import 'core-js/modules/es.object.keys'; -import 'core-js/modules/es.object.get-own-property-names'; -import 'core-js/modules/es.object.freeze'; -import 'core-js/modules/es.object.seal'; -import 'core-js/modules/es.object.prevent-extensions'; -import 'core-js/modules/es.object.is-frozen'; -import 'core-js/modules/es.object.is-sealed'; -import 'core-js/modules/es.object.is-extensible'; -import 'core-js/modules/es.object.assign'; -import 'core-js/modules/es.object.is'; -import 'core-js/modules/es.object.set-prototype-of'; -import 'core-js/modules/es.object.to-string'; -import 'core-js/modules/es.object.entries'; -import 'core-js/modules/es.object.values'; -import 'core-js/modules/es.object.get-own-property-descriptors'; -import 'core-js/modules/es.object.from-entries'; - -// ES2015 array capabilities -import 'core-js/modules/es.array.concat'; -import 'core-js/modules/es.array.is-array'; -import 'core-js/modules/es.array.from'; -import 'core-js/modules/es.array.of'; -import 'core-js/modules/es.array.join'; -import 'core-js/modules/es.array.slice'; -import 'core-js/modules/es.array.splice'; -import 'core-js/modules/es.array.sort'; -import 'core-js/modules/es.array.for-each'; -import 'core-js/modules/es.array.map'; -import 'core-js/modules/es.array.filter'; -import 'core-js/modules/es.array.some'; -import 'core-js/modules/es.array.every'; -import 'core-js/modules/es.array.reduce'; -import 'core-js/modules/es.array.reduce-right'; -import 'core-js/modules/es.array.index-of'; -import 'core-js/modules/es.array.last-index-of'; -import 'core-js/modules/es.array.copy-within'; -import 'core-js/modules/es.array.fill'; -import 'core-js/modules/es.array.find'; -import 'core-js/modules/es.array.find-index'; -import 'core-js/modules/es.array.iterator'; -import 'core-js/modules/es.array.includes'; -import 'core-js/modules/es.array.flat'; -import 'core-js/modules/es.array.flat-map'; - -// ES2015 string capabilities -import 'core-js/modules/es.string.from-code-point'; -import 'core-js/modules/es.string.raw'; -import 'core-js/modules/es.string.trim'; -import 'core-js/modules/es.string.iterator'; -import 'core-js/modules/es.string.code-point-at'; -import 'core-js/modules/es.string.ends-with'; -import 'core-js/modules/es.string.includes'; -import 'core-js/modules/es.string.repeat'; -import 'core-js/modules/es.string.starts-with'; -import 'core-js/modules/es.string.anchor'; -import 'core-js/modules/es.string.big'; -import 'core-js/modules/es.string.blink'; -import 'core-js/modules/es.string.bold'; -import 'core-js/modules/es.string.fixed'; -import 'core-js/modules/es.string.fontcolor'; -import 'core-js/modules/es.string.fontsize'; -import 'core-js/modules/es.string.italics'; -import 'core-js/modules/es.string.link'; -import 'core-js/modules/es.string.small'; -import 'core-js/modules/es.string.strike'; -import 'core-js/modules/es.string.sub'; -import 'core-js/modules/es.string.sup'; -import 'core-js/modules/es.string.match'; -import 'core-js/modules/es.string.replace'; -import 'core-js/modules/es.string.search'; -import 'core-js/modules/es.string.split'; - -import 'core-js/modules/es.parse-int'; -import 'core-js/modules/es.parse-float'; - -import 'core-js/es/number'; -import 'core-js/es/math'; -import 'core-js/es/date'; - -import 'core-js/modules/es.regexp.constructor'; -import 'core-js/modules/es.regexp.to-string'; -import 'core-js/modules/es.regexp.flags'; - -import 'core-js/modules/es.map'; -import 'core-js/modules/es.weak-map'; -import 'core-js/modules/es.set'; -import 'core-js/modules/web.dom-collections.for-each'; -import 'core-js/modules/web.dom-collections.iterator'; -import 'core-js/modules/es.promise'; -import 'core-js/modules/es.json.to-string-tag'; - -import 'regenerator-runtime/runtime'; - -// Zone.js -import 'zone.js/plugins/zone-legacy'; diff --git a/packages/angular_devkit/build_angular/src/webpack/jit-polyfills.js b/packages/angular_devkit/build_angular/src/webpack/jit-polyfills.js deleted file mode 100644 index 5df753e031d4..000000000000 --- a/packages/angular_devkit/build_angular/src/webpack/jit-polyfills.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import 'core-js/proposals/reflect-metadata'; diff --git a/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-context.html b/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-context.html index a578cb4b7dcf..587278156358 100644 --- a/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-context.html +++ b/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-context.html @@ -31,7 +31,6 @@ %MAPPINGS% - %SCRIPTS% diff --git a/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-debug.html b/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-debug.html index 4f64eef5848b..fed09ab2a369 100644 --- a/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-debug.html +++ b/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma-debug.html @@ -33,7 +33,6 @@ %MAPPINGS% - %SCRIPTS% diff --git a/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma.ts b/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma.ts index ce24f7cf9fca..dd2d410d5296 100644 --- a/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma.ts +++ b/packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma.ts @@ -299,7 +299,6 @@ function fallbackMiddleware() { const alwaysServe = [ `/${KARMA_APPLICATION_PATH}/runtime.js`, `/${KARMA_APPLICATION_PATH}/polyfills.js`, - `/${KARMA_APPLICATION_PATH}/polyfills-es5.js`, `/${KARMA_APPLICATION_PATH}/scripts.js`, `/${KARMA_APPLICATION_PATH}/styles.css`, `/${KARMA_APPLICATION_PATH}/vendor.js`, diff --git a/packages/angular_devkit/build_angular/src/webpack/utils/helpers.ts b/packages/angular_devkit/build_angular/src/webpack/utils/helpers.ts index f07178b07c91..32302cc3096b 100644 --- a/packages/angular_devkit/build_angular/src/webpack/utils/helpers.ts +++ b/packages/angular_devkit/build_angular/src/webpack/utils/helpers.ts @@ -113,7 +113,7 @@ export function getEsVersionForFileName( } export function isPolyfillsEntry(name: string): boolean { - return name === 'polyfills' || name === 'polyfills-es5'; + return name === 'polyfills'; } export function getWatchOptions(poll: number | undefined): Configuration['watchOptions'] { diff --git a/tests/legacy-cli/e2e/tests/build/polyfills.ts b/tests/legacy-cli/e2e/tests/build/polyfills.ts index 50da87ca5d58..0cbe26254f20 100644 --- a/tests/legacy-cli/e2e/tests/build/polyfills.ts +++ b/tests/legacy-cli/e2e/tests/build/polyfills.ts @@ -1,6 +1,5 @@ import { oneLineTrim } from 'common-tags'; import { - appendToFile, expectFileSizeToBeUnder, expectFileToExist, expectFileToMatch, @@ -10,38 +9,22 @@ import { ng } from '../../utils/process'; import { expectToFail } from '../../utils/utils'; export default async function () { - // Enable ES5 polyfills to run both size checks - await appendToFile('.browserslistrc', 'IE 11'); - await ng('build', '--aot=false', '--configuration=development'); - // files were created successfully - await expectFileToMatch('dist/test-project/polyfills-es5.js', 'core-js/es/reflect'); - await expectFileToMatch('dist/test-project/polyfills-es5.js', 'zone.js'); - - await expectFileToMatch( - 'dist/test-project/index.html', - oneLineTrim` - - - - - - - `); - - await writeFile('.browserslistrc', 'IE 10'); - await ng('build', '--configuration=development'); - await expectFileToMatch('dist/test-project/polyfills-es5.js', 'core-js'); - await expectFileToMatch('dist/test-project/index.html', oneLineTrim` - - - - - - `); -}