@@ -60,7 +60,7 @@ module.exports = function ctx(compiler, options) {
60
60
}
61
61
}
62
62
63
- function invalid ( ... args ) {
63
+ function invalid ( callback ) {
64
64
if ( context . state ) {
65
65
context . options . reporter ( context . options , {
66
66
log,
@@ -70,9 +70,7 @@ module.exports = function ctx(compiler, options) {
70
70
71
71
// We are now in invalid state
72
72
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' ) {
76
74
callback ( ) ;
77
75
}
78
76
}
@@ -94,26 +92,11 @@ module.exports = function ctx(compiler, options) {
94
92
}
95
93
96
94
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 ) ;
117
100
} ) ;
118
101
119
102
return context ;
0 commit comments