@@ -72,6 +72,7 @@ class ForkTsCheckerWebpackPlugin {
72
72
static ONE_CPU_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 1 ) ;
73
73
static TWO_CPUS_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 2 ) ;
74
74
75
+ typescriptPath : string ;
75
76
options : Partial < Options > ;
76
77
tsconfig : string ;
77
78
compilerOptions : object ;
@@ -114,7 +115,7 @@ class ForkTsCheckerWebpackPlugin {
114
115
115
116
vue : boolean ;
116
117
117
- constructor ( options ?: Partial < Options > ) {
118
+ constructor ( typescriptPath ?: string | null , options ?: Partial < Options > ) {
118
119
options = options || ( { } as Options ) ;
119
120
this . options = Object . assign ( { } , options ) ;
120
121
@@ -169,9 +170,12 @@ class ForkTsCheckerWebpackPlugin {
169
170
this . emitCallback = this . createNoopEmitCallback ( ) ;
170
171
this . doneCallback = this . createDoneCallback ( ) ;
171
172
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 ;
173
176
this . tslintVersion = this . tslint
174
- ? require ( 'tslint' ) . Linter . VERSION
177
+ ? // tslint:disable-next-line:no-implicit-dependencies
178
+ require ( 'tslint' ) . Linter . VERSION
175
179
: undefined ;
176
180
177
181
this . vue = options . vue === true ; // default false
@@ -563,6 +567,7 @@ class ForkTsCheckerWebpackPlugin {
563
567
? [ ]
564
568
: [ '--max-old-space-size=' + this . memoryLimit ] ,
565
569
env : Object . assign ( { } , process . env , {
570
+ TYPESCRIPT_PATH : this . typescriptPath ,
566
571
TSCONFIG : this . tsconfigPath ,
567
572
COMPILER_OPTIONS : JSON . stringify ( this . compilerOptions ) ,
568
573
TSLINT : this . tslintPath || '' ,
0 commit comments