@@ -69,6 +69,7 @@ class ForkTsCheckerWebpackPlugin {
69
69
static ONE_CPU_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 1 ) ;
70
70
static TWO_CPUS_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 2 ) ;
71
71
72
+ typescriptPath : string ;
72
73
options : Partial < Options > ;
73
74
tsconfig : string ;
74
75
tslint : string | true ;
@@ -109,7 +110,7 @@ class ForkTsCheckerWebpackPlugin {
109
110
110
111
vue : boolean ;
111
112
112
- constructor ( options ?: Partial < Options > ) {
113
+ constructor ( typescriptPath ?: string | null , options ?: Partial < Options > ) {
113
114
options = options || ( { } as Options ) ;
114
115
this . options = Object . assign ( { } , options ) ;
115
116
@@ -159,9 +160,12 @@ class ForkTsCheckerWebpackPlugin {
159
160
this . emitCallback = this . createNoopEmitCallback ( ) ;
160
161
this . doneCallback = this . createDoneCallback ( ) ;
161
162
162
- this . typescriptVersion = require ( 'typescript' ) . version ;
163
+ // tslint:disable-next-line:no-implicit-dependencies
164
+ this . typescriptPath = typescriptPath || require . resolve ( 'typescript' ) ;
165
+ this . typescriptVersion = require ( typescriptPath ) . version ;
163
166
this . tslintVersion = this . tslint
164
- ? require ( 'tslint' ) . Linter . VERSION
167
+ ? // tslint:disable-next-line:no-implicit-dependencies
168
+ require ( 'tslint' ) . Linter . VERSION
165
169
: undefined ;
166
170
167
171
this . vue = options . vue === true ; // default false
@@ -553,6 +557,7 @@ class ForkTsCheckerWebpackPlugin {
553
557
? [ ]
554
558
: [ '--max-old-space-size=' + this . memoryLimit ] ,
555
559
env : Object . assign ( { } , process . env , {
560
+ TYPESCRIPT_PATH : this . typescriptPath ,
556
561
TSCONFIG : this . tsconfigPath ,
557
562
TSLINT : this . tslintPath || '' ,
558
563
WATCH : this . isWatching ? this . watchPaths . join ( '|' ) : '' ,
0 commit comments