@@ -60,7 +60,7 @@ module.exports = function ctx(compiler, options) {
6060 }
6161 }
6262
63- function invalid ( ... args ) {
63+ function invalid ( callback ) {
6464 if ( context . state ) {
6565 context . options . reporter ( context . options , {
6666 log,
@@ -70,9 +70,7 @@ module.exports = function ctx(compiler, options) {
7070
7171 // We are now in invalid state
7272 context . state = false ;
73- // resolve async
74- if ( args . length === 2 && typeof args [ 1 ] === 'function' ) {
75- const [ , callback ] = args ;
73+ if ( callback && typeof callback === 'function' ) {
7674 callback ( ) ;
7775 }
7876 }
@@ -94,26 +92,11 @@ module.exports = function ctx(compiler, options) {
9492 }
9593
9694 context . rebuild = rebuild ;
97- context . compiler . plugin ( 'invalid' , invalid ) ;
98- context . compiler . plugin ( 'run' , invalid ) ;
99-
100- context . compiler . plugin ( 'done' , ( stats ) => {
101- // clean up the time offset
102- if ( options . watchOffset > 0 ) {
103- stats . startTime -= options . watchOffset ;
104- }
105-
106- done ( stats ) ;
107- } ) ;
108-
109- context . compiler . plugin ( 'watch-run' , ( watcher , callback ) => {
110- // apply a fix for compiler.watch, if watchOffset is greater than 0:
111- // ff0000-ad-tech/wp-plugin-watch-offset
112- // offset start-time
113- if ( options . watchOffset > 0 ) {
114- watcher . startTime += options . watchOffset ;
115- }
116- invalid ( watcher , callback ) ;
95+ context . compiler . hooks . invalid . tap ( 'WebpackDevMiddleware' , invalid ) ;
96+ context . compiler . hooks . run . tap ( 'WebpackDevMiddleware' , invalid ) ;
97+ context . compiler . hooks . done . tap ( 'WebpackDevMiddleware' , done ) ;
98+ context . compiler . hooks . watchRun . tap ( 'WebpackDevMiddleware' , ( comp , callback ) => {
99+ invalid ( callback ) ;
117100 } ) ;
118101
119102 return context ;
0 commit comments