@@ -72,6 +72,7 @@ class ForkTsCheckerWebpackPlugin {
7272 static ONE_CPU_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 1 ) ;
7373 static TWO_CPUS_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 2 ) ;
7474
75+ typescriptPath : string ;
7576 options : Partial < Options > ;
7677 tsconfig : string ;
7778 compilerOptions : object ;
@@ -114,7 +115,7 @@ class ForkTsCheckerWebpackPlugin {
114115
115116 vue : boolean ;
116117
117- constructor ( options ?: Partial < Options > ) {
118+ constructor ( typescriptPath ?: string | null , options ?: Partial < Options > ) {
118119 options = options || ( { } as Options ) ;
119120 this . options = Object . assign ( { } , options ) ;
120121
@@ -169,9 +170,12 @@ class ForkTsCheckerWebpackPlugin {
169170 this . emitCallback = this . createNoopEmitCallback ( ) ;
170171 this . doneCallback = this . createDoneCallback ( ) ;
171172
172- this . typescriptVersion = require ( 'typescript' ) . version ;
173+ // tslint:disable-next-line:no-implicit-dependencies
174+ this . typescriptPath = typescriptPath || require . resolve ( 'typescript' ) ;
175+ this . typescriptVersion = require ( typescriptPath ) . version ;
173176 this . tslintVersion = this . tslint
174- ? require ( 'tslint' ) . Linter . VERSION
177+ ? // tslint:disable-next-line:no-implicit-dependencies
178+ require ( 'tslint' ) . Linter . VERSION
175179 : undefined ;
176180
177181 this . vue = options . vue === true ; // default false
@@ -563,6 +567,7 @@ class ForkTsCheckerWebpackPlugin {
563567 ? [ ]
564568 : [ '--max-old-space-size=' + this . memoryLimit ] ,
565569 env : Object . assign ( { } , process . env , {
570+ TYPESCRIPT_PATH : this . typescriptPath ,
566571 TSCONFIG : this . tsconfigPath ,
567572 COMPILER_OPTIONS : JSON . stringify ( this . compilerOptions ) ,
568573 TSLINT : this . tslintPath || '' ,
0 commit comments