@@ -5,7 +5,6 @@ import * as path from 'path';
5
5
import * as ts from 'typescript' ;
6
6
7
7
const ContextElementDependency = require ( 'webpack/lib/dependencies/ContextElementDependency' ) ;
8
- const treeKill = require ( 'tree-kill' ) ;
9
8
10
9
import { WebpackResourceLoader } from './resource_loader' ;
11
10
import { WebpackCompilerHost } from './compiler_host' ;
@@ -507,28 +506,24 @@ export class AngularCompilerPlugin implements Tapable {
507
506
forkOptions ) ;
508
507
509
508
// Handle child process exit.
510
- const handleChildProcessExit = ( ) => {
511
- this . _killForkedTypeChecker ( ) ;
512
- const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
513
- 'Falling back to type checking on main thread.' ;
514
- this . _warnings . push ( msg ) ;
515
- } ;
516
- this . _typeCheckerProcess . once ( 'exit' , handleChildProcessExit ) ;
517
- this . _typeCheckerProcess . once ( 'SIGINT' , handleChildProcessExit ) ;
518
- this . _typeCheckerProcess . once ( 'uncaughtException' , handleChildProcessExit ) ;
519
-
520
- // Handle parent process exit.
521
- const handleParentProcessExit = ( ) => this . _killForkedTypeChecker ( ) ;
522
- process . once ( 'exit' , handleParentProcessExit ) ;
523
- process . once ( 'SIGINT' , handleParentProcessExit ) ;
524
- process . once ( 'uncaughtException' , handleParentProcessExit ) ;
509
+ this . _typeCheckerProcess . once ( 'exit' , ( _ , signal ) => {
510
+ this . _typeCheckerProcess = undefined ;
511
+
512
+ // If process exited not because of SIGTERM (see _killForkedTypeChecker), than something
513
+ // went wrong and it should fallback to type checking on the main thread.
514
+ if ( signal !== 'SIGTERM' ) {
515
+ this . _forkTypeChecker = false ;
516
+ const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
517
+ 'Falling back to type checking on main thread.' ;
518
+ this . _warnings . push ( msg ) ;
519
+ }
520
+ } ) ;
525
521
}
526
522
527
523
private _killForkedTypeChecker ( ) {
528
- if ( this . _typeCheckerProcess && this . _typeCheckerProcess . pid ) {
529
- treeKill ( this . _typeCheckerProcess . pid , 'SIGTERM' ) ;
524
+ if ( this . _typeCheckerProcess ) {
525
+ this . _typeCheckerProcess . kill ( 'SIGTERM' ) ;
530
526
this . _typeCheckerProcess = undefined ;
531
- this . _forkTypeChecker = false ;
532
527
}
533
528
}
534
529
0 commit comments