@@ -42,14 +42,13 @@ export interface Loader {
42
42
clearDependencies : ( ) => void ;
43
43
emitFile : ( fileName : string , text : string ) => void ;
44
44
options : {
45
- atl ?: {
46
- }
45
+ ts ?: LoaderConfig
47
46
} ;
48
47
}
49
48
50
49
export type QueryOptions = LoaderConfig & ts . CompilerOptions ;
51
50
52
- function getRootCompiler ( compiler ) {
51
+ export function getRootCompiler ( compiler ) {
53
52
if ( compiler . parentCompilation ) {
54
53
return getRootCompiler ( compiler . parentCompilation . compiler ) ;
55
54
} else {
@@ -73,20 +72,25 @@ const BABEL_ERROR = colors.red(`\n\nBabel compiler cannot be found, please add i
73
72
` ) ;
74
73
75
74
let id = 0 ;
76
- export function ensureInstance ( webpack : Loader , query : QueryOptions , instanceName : string ) : Instance {
77
- const rootCompiler = getRootCompiler ( webpack . _compiler ) ;
78
- const watching = isWatching ( rootCompiler ) ;
79
-
80
- let exInstance = resolveInstance ( webpack . _compiler , instanceName ) ;
75
+ export function ensureInstance (
76
+ webpack : Loader ,
77
+ query : QueryOptions ,
78
+ options : LoaderConfig ,
79
+ instanceName : string ,
80
+ rootCompiler : any
81
+ ) : Instance {
82
+ let exInstance = resolveInstance ( rootCompiler , instanceName ) ;
81
83
if ( exInstance ) {
82
84
return exInstance ;
83
85
}
84
86
87
+ const watching = isWatching ( rootCompiler ) ;
88
+
85
89
const context = rootCompiler . context ;
86
90
let compilerInfo = setupTs ( query . compiler ) ;
87
91
let { tsImpl } = compilerInfo ;
88
92
89
- let { configFilePath, compilerConfig, loaderConfig } = readConfigFile ( context , query , tsImpl ) ;
93
+ let { configFilePath, compilerConfig, loaderConfig } = readConfigFile ( context , query , options , tsImpl ) ;
90
94
91
95
applyDefaults (
92
96
configFilePath ,
@@ -264,6 +268,7 @@ function absolutize(fileName: string, context: string) {
264
268
export function readConfigFile (
265
269
context : string ,
266
270
query : QueryOptions ,
271
+ options : LoaderConfig ,
267
272
tsImpl : typeof ts
268
273
) : Configs {
269
274
let configFilePath : string ;
@@ -290,7 +295,6 @@ export function readConfigFile(
290
295
}
291
296
292
297
let jsonConfigFile = tsImpl . readConfigFile ( configFilePath , tsImpl . sys . readFile ) ;
293
-
294
298
let compilerConfig = tsImpl . parseJsonConfigFileContent (
295
299
jsonConfigFile . config ,
296
300
tsImpl . sys ,
@@ -302,9 +306,11 @@ export function readConfigFile(
302
306
return {
303
307
configFilePath,
304
308
compilerConfig,
305
- loaderConfig : _ . defaults < LoaderConfig , LoaderConfig > (
309
+ loaderConfig : _ . defaults (
306
310
query ,
307
- jsonConfigFile . config . awesomeTypescriptLoaderOptions )
311
+ jsonConfigFile . config . awesomeTypescriptLoaderOptions ,
312
+ options
313
+ )
308
314
} ;
309
315
}
310
316
0 commit comments