Skip to content

Commit 0b126f6

Browse files
filipesilvahansl
authored andcommitted
fix(@angular-devkit/build-angular): never split polyfills in test
Fix #10485
1 parent 67316ec commit 0b126f6

File tree

1 file changed

+21
-26
lines changed
  • packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs

1 file changed

+21
-26
lines changed

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

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
// tslint:disable
9-
// TODO: cleanup this file, it's copied as is from Angular CLI.
108

11-
import * as path from 'path';
129
import * as glob from 'glob';
13-
14-
// import { CliConfig } from '../config';
10+
import * as path from 'path';
11+
import * as webpack from 'webpack';
1512
import { WebpackConfigOptions, WebpackTestOptions } from '../build-options';
1613

1714

@@ -23,19 +20,20 @@ import { WebpackConfigOptions, WebpackTestOptions } from '../build-options';
2320
*
2421
*/
2522

26-
27-
export function getTestConfig(wco: WebpackConfigOptions<WebpackTestOptions>) {
23+
export function getTestConfig(
24+
wco: WebpackConfigOptions<WebpackTestOptions>,
25+
): webpack.Configuration {
2826
const { root, buildOptions } = wco;
2927

30-
const extraRules: any[] = [];
31-
const extraPlugins: any[] = [];
28+
const extraRules: webpack.Rule[] = [];
29+
const extraPlugins: webpack.Plugin[] = [];
3230

3331
// if (buildOptions.codeCoverage && CliConfig.fromProject()) {
3432
if (buildOptions.codeCoverage) {
3533
const codeCoverageExclude = buildOptions.codeCoverageExclude;
36-
let exclude: (string | RegExp)[] = [
34+
const exclude: (string | RegExp)[] = [
3735
/\.(e2e|spec)\.ts$/,
38-
/node_modules/
36+
/node_modules/,
3937
];
4038

4139
if (codeCoverageExclude) {
@@ -51,7 +49,7 @@ export function getTestConfig(wco: WebpackConfigOptions<WebpackTestOptions>) {
5149
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader',
5250
options: { esModules: true },
5351
enforce: 'post',
54-
exclude
52+
exclude,
5553
});
5654
}
5755

@@ -60,34 +58,31 @@ export function getTestConfig(wco: WebpackConfigOptions<WebpackTestOptions>) {
6058
resolve: {
6159
mainFields: [
6260
...(wco.supportES2015 ? ['es2015'] : []),
63-
'browser', 'module', 'main'
64-
]
61+
'browser', 'module', 'main',
62+
],
6563
},
6664
devtool: buildOptions.sourceMap ? 'inline-source-map' : 'eval',
6765
entry: {
68-
main: path.resolve(root, buildOptions.main)
66+
main: path.resolve(root, buildOptions.main),
6967
},
7068
module: {
71-
rules: [].concat(extraRules as any)
69+
rules: extraRules,
7270
},
7371
plugins: extraPlugins,
7472
optimization: {
75-
// runtimeChunk: 'single',
7673
splitChunks: {
77-
chunks: buildOptions.commonChunk ? 'all' : 'initial',
74+
chunks: ((chunk: { name: string }) => chunk.name !== 'polyfills'),
7875
cacheGroups: {
7976
vendors: false,
8077
vendor: {
8178
name: 'vendor',
8279
chunks: 'initial',
83-
test: (module: any, chunks: Array<{ name: string }>) => {
84-
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
85-
return /[\\/]node_modules[\\/]/.test(moduleName)
86-
&& !chunks.some(({ name }) => name === 'polyfills');
87-
},
80+
test: /[\\/]node_modules[\\/]/,
8881
},
89-
}
90-
}
82+
},
83+
},
9184
},
92-
};
85+
// Webpack typings don't yet include the function form for 'chunks',
86+
// or the built-in vendors cache group.
87+
} as {} as webpack.Configuration;
9388
}

0 commit comments

Comments
 (0)