Skip to content

Commit 888145e

Browse files
filipesilvaalexeagle
authored andcommitted
fix(@angular-devkit/build-angular): never split polyfill chunks
Fix #14280
1 parent a41c185 commit 888145e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as webpack from 'webpack';
1111
import { IndexHtmlWebpackPlugin } from '../../plugins/index-html-webpack-plugin';
1212
import { generateEntryPoints } from '../../utilities/package-chunk-sort';
1313
import { WebpackConfigOptions } from '../build-options';
14-
import { getSourceMapDevTool, normalizeExtraEntryPoints } from './utils';
14+
import { getSourceMapDevTool, isPolyfillsEntry, normalizeExtraEntryPoints } from './utils';
1515

1616
const SubresourceIntegrityPlugin = require('webpack-subresource-integrity');
1717

@@ -114,7 +114,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
114114
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
115115

116116
return /[\\/]node_modules[\\/]/.test(moduleName)
117-
&& !chunks.some(({ name }) => name === 'polyfills' || name === 'polyfills-es5'
117+
&& !chunks.some(({ name }) => isPolyfillsEntry(name)
118118
|| globalStylesBundleNames.includes(name));
119119
},
120120
},

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as glob from 'glob';
1010
import * as path from 'path';
1111
import * as webpack from 'webpack';
1212
import { WebpackConfigOptions, WebpackTestOptions } from '../build-options';
13-
import { getSourceMapDevTool } from './utils';
13+
import { getSourceMapDevTool, isPolyfillsEntry } from './utils';
1414

1515

1616
/**
@@ -85,7 +85,7 @@ export function getTestConfig(
8585
plugins: extraPlugins,
8686
optimization: {
8787
splitChunks: {
88-
chunks: ((chunk: { name: string }) => chunk.name !== 'polyfills'),
88+
chunks: ((chunk: { name: string }) => !isPolyfillsEntry(chunk.name)),
8989
cacheGroups: {
9090
vendors: false,
9191
vendor: {
@@ -95,7 +95,7 @@ export function getTestConfig(
9595
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
9696

9797
return /[\\/]node_modules[\\/]/.test(moduleName)
98-
&& !chunks.some(({ name }) => name === 'polyfills');
98+
&& !chunks.some(({ name }) => isPolyfillsEntry(name));
9999
},
100100
},
101101
},

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

+4
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ export function getEsVersionForFileName(
101101
return scriptTargetOverride && esVersionInFileName ?
102102
'-' + ScriptTarget[scriptTargetOverride].toLowerCase() : '';
103103
}
104+
105+
export function isPolyfillsEntry(name: string) {
106+
return name === 'polyfills' || name === 'polyfills-es5';
107+
}

0 commit comments

Comments
 (0)