Skip to content

Commit 2539472

Browse files
committed
don't reload when there are errors
1 parent 7966c58 commit 2539472

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

packages/@angular/cli/models/webpack-configs/test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as webpack from 'webpack';
44

55
import { CliConfig } from '../config';
66
import { WebpackTestOptions } from '../webpack-test-config';
7-
import { KarmaWebpackEmitlessError } from '../../plugins/karma-webpack-emitless-error';
87

98

109
/**
@@ -66,7 +65,7 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
6665
chunks: ['main'],
6766
minChunks: (module: any) => module.resource && module.resource.startsWith(nodeModules)
6867
}),
69-
new KarmaWebpackEmitlessError()
68+
// new KarmaWebpackEmitlessError()
7069
].concat(extraPlugins)
7170
};
7271
}

packages/@angular/cli/plugins/karma-webpack-emitless-error.ts

-20
This file was deleted.

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

+19-6
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
9494
const webpackMiddlewareConfig = {
9595
noInfo: true, // Hide webpack output because its noisy.
9696
watchOptions: { poll: testConfig.poll },
97-
publicPath: '/_karma_webpack_/'
97+
publicPath: '/_karma_webpack_/',
98+
stats: { // Also prevent chunk and module display output, cleaner look. Only emit errors.
99+
assets: false,
100+
colors: true,
101+
version: false,
102+
hash: false,
103+
timings: false,
104+
chunks: false,
105+
chunkModules: false
106+
}
98107
};
99108

100109
// If Karma is being ran in single run mode, throw errors.
@@ -156,15 +165,19 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
156165
});
157166
});
158167

159-
compiler.plugin('done', () => {
160-
emitter.refreshFiles();
161-
isBlocked = false;
162-
blocked.forEach((cb) => cb());
163-
blocked = [];
168+
compiler.plugin('done', (stats: any) => {
169+
// Don't refresh karma when there are webpack errors.
170+
if (stats.compilation.errors.length === 0) {
171+
emitter.refreshFiles();
172+
isBlocked = false;
173+
blocked.forEach((cb) => cb());
174+
blocked = [];
175+
}
164176
});
165177

166178
const middleware = new webpackDevMiddleware(compiler, webpackMiddlewareConfig);
167179

180+
// Forward requests to webpack server.
168181
customFileHandlers.push({
169182
urlRegex: /^\/_karma_webpack_\/.*/,
170183
handler: function handler(req: any, res: any) {

0 commit comments

Comments
 (0)