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