Skip to content

Commit bda22ef

Browse files
committed
fix(@angular/cli): include polyfills before scripts in ng test
Fix angular#4545
1 parent 8b3e300 commit bda22ef

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

packages/@angular/cli/plugins/karma.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,6 @@ const init = (config) => {
6767
.map((file) => config.preprocessors[file])
6868
.map((arr) => arr.splice(arr.indexOf('@angular/cli'), 1, 'webpack', 'sourcemap'));
6969

70-
// Add polyfills file
71-
if (appConfig.polyfills) {
72-
const polyfillsFile = path.resolve(appRoot, appConfig.polyfills);
73-
const polyfillsPattern = {
74-
pattern: polyfillsFile,
75-
included: true,
76-
served: true,
77-
watched: true
78-
}
79-
Array.prototype.unshift.apply(config.files, [polyfillsPattern]);
80-
config.preprocessors[polyfillsFile] = ['webpack', 'sourcemap'];
81-
}
82-
8370
// Add global scripts
8471
if (appConfig.scripts && appConfig.scripts.length > 0) {
8572
const globalScriptPatterns = appConfig.scripts
@@ -98,6 +85,19 @@ const init = (config) => {
9885
// karma already has a reference to the existing array.
9986
Array.prototype.unshift.apply(config.files, globalScriptPatterns);
10087
}
88+
89+
// Add polyfills file before everything else
90+
if (appConfig.polyfills) {
91+
const polyfillsFile = path.resolve(appRoot, appConfig.polyfills);
92+
const polyfillsPattern = {
93+
pattern: polyfillsFile,
94+
included: true,
95+
served: true,
96+
watched: true
97+
}
98+
Array.prototype.unshift.apply(config.files, [polyfillsPattern]);
99+
config.preprocessors[polyfillsFile] = ['webpack', 'sourcemap'];
100+
}
101101
}
102102

103103
init.$inject = ['config'];

0 commit comments

Comments
 (0)