@@ -197,7 +197,6 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
197
197
} ;
198
198
199
199
var compilerOptions : typescript . CompilerOptions = {
200
- module : 1 /* CommonJS */
201
200
} ;
202
201
203
202
// Load any available tsconfig.json file
@@ -275,14 +274,14 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
275
274
instance . compilerOptions = objectAssign < typescript . CompilerOptions > ( compilerOptions , configParseResult . options ) ;
276
275
filesToLoad = configParseResult . fileNames ;
277
276
278
- var libFileName = 'lib.d.ts' ;
279
-
280
- // Special handling for ES6 targets
281
- if ( compilerOptions . target == 2 /* ES6 */ ) {
277
+ // if `module` is not specified and not using ES6 target, default to CJS module output
278
+ if ( compilerOptions . module == null && compilerOptions . target !== 2 /* ES6 */ ) {
279
+ compilerOptions . module = 1 /* CommonJS */
280
+ }
281
+ // special handling for TS 1.6 and target: es6
282
+ else if ( compilerCompatible && semver . lt ( compiler . version , '1.7.3-0' ) && compilerOptions . target == 2 /* ES6 */ ) {
282
283
compilerOptions . module = 0 /* None */ ;
283
- libFileName = 'lib.es6.d.ts' ;
284
284
}
285
- libFileName = path . join ( path . dirname ( require . resolve ( loaderOptions . compiler ) ) , libFileName ) ;
286
285
287
286
if ( loaderOptions . transpileOnly ) {
288
287
// quick return for transpiling
@@ -297,10 +296,6 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
297
296
return { instance : instances [ loaderOptions . instance ] = { compiler, compilerOptions, loaderOptions, files } } ;
298
297
}
299
298
300
- if ( ! compilerOptions . noLib ) {
301
- filesToLoad . push ( libFileName ) ;
302
- }
303
-
304
299
// Load initial files (core lib files, any files specified in tsconfig.json)
305
300
filesToLoad . forEach ( filePath => {
306
301
filePath = path . normalize ( filePath ) ;
@@ -356,7 +351,7 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
356
351
} ,
357
352
getCurrentDirectory : ( ) => process . cwd ( ) ,
358
353
getCompilationSettings : ( ) => compilerOptions ,
359
- getDefaultLibFileName : options => libFileName ,
354
+ getDefaultLibFileName : options => compiler . getDefaultLibFilePath ( options ) ,
360
355
getNewLine : ( ) => newLine ,
361
356
log : log ,
362
357
resolveModuleNames : ( moduleNames : string [ ] , containingFile : string ) => {
0 commit comments