@@ -42,9 +42,15 @@ export class PathsPlugin implements Tapable {
4242
4343 private _absoluteBaseUrl : string ;
4444
45- private static _loadOptionsFromTsConfig ( tsConfigPath : string , host : ts . CompilerHost ) :
45+ private static _loadOptionsFromTsConfig ( tsConfigPath : string , host ? : ts . CompilerHost ) :
4646 ts . CompilerOptions {
47- const tsConfig = ts . readConfigFile ( tsConfigPath , ( path : string ) => host . readFile ( path ) ) ;
47+ const tsConfig = ts . readConfigFile ( tsConfigPath , ( path : string ) => {
48+ if ( host ) {
49+ return host . readFile ( path ) ;
50+ } else {
51+ return ts . sys . readFile ( path ) ;
52+ }
53+ } ) ;
4854 if ( tsConfig . error ) {
4955 throw tsConfig . error ;
5056 }
@@ -58,16 +64,16 @@ export class PathsPlugin implements Tapable {
5864 }
5965 this . _tsConfigPath = options . tsConfigPath ;
6066
61- if ( options . hasOwnProperty ( 'compilerHost ' ) ) {
62- this . _host = options . compilerHost ;
67+ if ( options . hasOwnProperty ( 'compilerOptions ' ) ) {
68+ this . _compilerOptions = Object . assign ( { } , options . compilerOptions ) ;
6369 } else {
64- this . _host = ts . createCompilerHost ( this . _compilerOptions , false ) ;
70+ this . _compilerOptions = PathsPlugin . _loadOptionsFromTsConfig ( this . _tsConfigPath , null ) ;
6571 }
6672
67- if ( options . hasOwnProperty ( 'compilerOptions ' ) ) {
68- this . _compilerOptions = Object . assign ( { } , options . compilerOptions ) ;
73+ if ( options . hasOwnProperty ( 'compilerHost ' ) ) {
74+ this . _host = options . compilerHost ;
6975 } else {
70- this . _compilerOptions = PathsPlugin . _loadOptionsFromTsConfig ( this . _tsConfigPath , this . _host ) ;
76+ this . _host = ts . createCompilerHost ( this . _compilerOptions , false ) ;
7177 }
7278
7379 this . source = 'described-resolve' ;
0 commit comments