@@ -23,6 +23,7 @@ export interface ICompilerInstance {
23
23
tsState : State ;
24
24
babelImpl ?: any ;
25
25
compiledFiles : { [ key :string ] : boolean } ;
26
+ configFilePath : string ;
26
27
compilerConfig : TsConfig ;
27
28
loaderConfig : LoaderConfig ;
28
29
externalsInvoked : boolean ;
@@ -155,7 +156,7 @@ export function ensureInstance(webpack: IWebPack, query: QueryOptions, instanceN
155
156
tsImpl,
156
157
} ;
157
158
158
- let { compilerConfig, loaderConfig } = readConfigFile ( process . cwd ( ) , query , tsImpl ) ;
159
+ let { configFilePath , compilerConfig, loaderConfig } = readConfigFile ( process . cwd ( ) , query , tsImpl ) ;
159
160
160
161
applyDefaults ( compilerConfig , loaderConfig ) ;
161
162
let babelImpl = setupBabel ( loaderConfig ) ;
@@ -164,6 +165,7 @@ export function ensureInstance(webpack: IWebPack, query: QueryOptions, instanceN
164
165
let forkChecker = loaderConfig . forkChecker && getRootCompiler ( webpack . _compiler ) . _tsFork ;
165
166
let tsState = new State (
166
167
loaderConfig ,
168
+ configFilePath ,
167
169
compilerConfig ,
168
170
compilerInfo
169
171
) ;
@@ -198,6 +200,7 @@ export function ensureInstance(webpack: IWebPack, query: QueryOptions, instanceN
198
200
babelImpl,
199
201
compiledFiles : { } ,
200
202
loaderConfig,
203
+ configFilePath,
201
204
compilerConfig,
202
205
externalsInvoked : false ,
203
206
checker : forkChecker
@@ -283,19 +286,36 @@ function applyDefaults(compilerConfig: TsConfig, loaderConfig: LoaderConfig) {
283
286
loaderConfig . externals . push . apply ( loaderConfig . externals , initialFiles ) ;
284
287
}
285
288
286
- function readConfigFile ( baseDir : string , query : QueryOptions , tsImpl : typeof ts ) : { compilerConfig : TsConfig , loaderConfig } {
289
+ export interface Configs {
290
+ configFilePath : string ;
291
+ compilerConfig : TsConfig ;
292
+ loaderConfig : LoaderConfig ;
293
+ }
294
+
295
+ function readConfigFile ( baseDir : string , query : QueryOptions , tsImpl : typeof ts ) : Configs {
287
296
let configFilePath : string ;
288
297
if ( query . tsconfig && query . tsconfig . match ( / \. j s o n $ / ) ) {
289
298
configFilePath = query . tsconfig ;
290
299
} else {
291
300
configFilePath = tsImpl . findConfigFile ( process . cwd ( ) , tsImpl . sys . fileExists ) ;
292
301
}
293
302
303
+ let existingOptions = tsImpl . convertCompilerOptionsFromJson ( query , process . cwd ( ) , 'atl.query' ) ;
304
+
294
305
if ( ! configFilePath ) {
295
- return null ;
306
+ return {
307
+ configFilePath : process . cwd ( ) ,
308
+ compilerConfig : tsImpl . parseJsonConfigFileContent (
309
+ { } ,
310
+ tsImpl . sys ,
311
+ process . cwd ( ) ,
312
+ _ . extend ( { } , ts . getDefaultCompilerOptions ( ) , existingOptions . options ) as ts . CompilerOptions ,
313
+ process . cwd ( )
314
+ ) ,
315
+ loaderConfig : query as LoaderConfig
316
+ } ;
296
317
}
297
318
298
- let existingOptions = tsImpl . convertCompilerOptionsFromJson ( query , process . cwd ( ) , 'atl.query' ) ;
299
319
let jsonConfigFile = tsImpl . readConfigFile ( configFilePath , tsImpl . sys . readFile ) ;
300
320
301
321
let compilerConfig = tsImpl . parseJsonConfigFileContent (
@@ -307,8 +327,11 @@ function readConfigFile(baseDir: string, query: QueryOptions, tsImpl: typeof ts)
307
327
) ;
308
328
309
329
return {
330
+ configFilePath,
310
331
compilerConfig,
311
- loaderConfig : _ . defaults ( query , jsonConfigFile . config . awesomeTypescriptLoaderOptions )
332
+ loaderConfig : _ . defaults < LoaderConfig , LoaderConfig > (
333
+ query ,
334
+ jsonConfigFile . config . awesomeTypescriptLoaderOptions )
312
335
} ;
313
336
}
314
337
0 commit comments