@@ -164,31 +164,33 @@ ForkTsCheckerWebpackPlugin.prototype.pluginStop = function () {
164164
165165ForkTsCheckerWebpackPlugin . prototype . pluginCompile = function ( ) {
166166 this . compiler . plugin ( 'compile' , function ( ) {
167- if ( this . cancellationToken ) {
168- // request cancellation if there is not finished job
169- this . cancellationToken . requestCancellation ( ) ;
170- this . compiler . applyPlugins ( 'fork-ts-checker-cancel' , this . cancellationToken ) ;
171- }
172- this . checkDone = false ;
173- this . compilationDone = false ;
174-
175- this . started = process . hrtime ( ) ;
167+ this . compiler . applyPluginsAsync ( 'fork-ts-checker-service-before-start' , function ( ) {
168+ if ( this . cancellationToken ) {
169+ // request cancellation if there is not finished job
170+ this . cancellationToken . requestCancellation ( ) ;
171+ this . compiler . applyPlugins ( 'fork-ts-checker-cancel' , this . cancellationToken ) ;
172+ }
173+ this . checkDone = false ;
174+ this . compilationDone = false ;
176175
177- // create new token for current job
178- this . cancellationToken = new CancellationToken ( ) ;
179- if ( ! this . service || ! this . service . connected ) {
180- this . spawnService ( ) ;
181- }
176+ this . started = process . hrtime ( ) ;
182177
183- try {
184- this . service . send ( this . cancellationToken ) ;
185- } catch ( error ) {
186- if ( ! this . silent && this . logger ) {
187- this . logger . error ( this . colors . red ( 'Cannot start checker service: ' + ( error ? error . toString ( ) : 'Unknown error' ) ) ) ;
178+ // create new token for current job
179+ this . cancellationToken = new CancellationToken ( ) ;
180+ if ( ! this . service || ! this . service . connected ) {
181+ this . spawnService ( ) ;
188182 }
189183
190- this . compiler . applyPlugins ( 'fork-ts-checker-service-start-error' , error ) ;
191- }
184+ try {
185+ this . service . send ( this . cancellationToken ) ;
186+ } catch ( error ) {
187+ if ( ! this . silent && this . logger ) {
188+ this . logger . error ( this . colors . red ( 'Cannot start checker service: ' + ( error ? error . toString ( ) : 'Unknown error' ) ) ) ;
189+ }
190+
191+ this . compiler . applyPlugins ( 'fork-ts-checker-service-start-error' , error ) ;
192+ }
193+ } . bind ( this ) ) ;
192194 } . bind ( this ) ) ;
193195} ;
194196
0 commit comments