@@ -91,8 +91,16 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
91
91
publicPath : '/_karma_webpack_/' ,
92
92
} ;
93
93
94
- // Finish Karma run early in case of compilation error.
95
- const compilationErrorCb = ( ) => emitter . emit ( 'run_complete' , [ ] , { exitCode : 1 } ) ;
94
+ const compilationErrorCb = ( error : string | undefined , errors : string [ ] ) => {
95
+ // Notify potential listeners of the compile error
96
+ emitter . emit ( 'compile_error' , errors ) ;
97
+
98
+ // Finish Karma run early in case of compilation error.
99
+ emitter . emit ( 'run_complete' , [ ] , { exitCode : 1 } ) ;
100
+
101
+ // Unblock any karma requests (potentially started using `karma run`)
102
+ unblock ( ) ;
103
+ }
96
104
webpackConfig . plugins . push ( new KarmaWebpackFailureCb ( compilationErrorCb ) ) ;
97
105
98
106
// Use existing config if any.
@@ -157,14 +165,18 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
157
165
} ) ;
158
166
} ) ;
159
167
168
+ function unblock ( ) {
169
+ isBlocked = false ;
170
+ blocked . forEach ( ( cb ) => cb ( ) ) ;
171
+ blocked = [ ] ;
172
+ }
173
+
160
174
compiler . plugin ( 'done' , ( stats : any ) => {
161
175
// Don't refresh karma when there are webpack errors.
162
176
if ( stats . compilation . errors . length === 0 ) {
163
177
emitter . refreshFiles ( ) ;
164
- isBlocked = false ;
165
- blocked . forEach ( ( cb ) => cb ( ) ) ;
166
- blocked = [ ] ;
167
178
}
179
+ unblock ( ) ;
168
180
} ) ;
169
181
170
182
webpackMiddleware = new webpackDevMiddleware ( compiler , webpackMiddlewareConfig ) ;
0 commit comments