@@ -18,7 +18,7 @@ import { tsConfigLoader } from 'tsconfig-paths/lib/tsconfig-loader';
1818
1919import includes from 'array-includes' ;
2020
21- let parseConfigFileTextToJson ;
21+ let ts ;
2222
2323const log = debug ( 'eslint-plugin-import:ExportMap' ) ;
2424
@@ -525,12 +525,15 @@ ExportMap.parse = function (path, content, context) {
525525 } ) ;
526526 try {
527527 if ( tsConfigInfo . tsConfigPath !== undefined ) {
528- const jsonText = fs . readFileSync ( tsConfigInfo . tsConfigPath ) . toString ( ) ;
529- if ( ! parseConfigFileTextToJson ) {
530- // this is because projects not using TypeScript won't have typescript installed
531- ( { parseConfigFileTextToJson } = require ( 'typescript' ) ) ;
532- }
533- return parseConfigFileTextToJson ( tsConfigInfo . tsConfigPath , jsonText ) . config ;
528+ // Projects not using TypeScript won't have `typescript` installed.
529+ if ( ! ts ) ( ts = require ( 'typescript' ) ) ;
530+
531+ const configFile = ts . readConfigFile ( tsConfigInfo . tsConfigPath , ts . sys . readFile ) ;
532+ return ts . parseJsonConfigFileContent (
533+ configFile . config ,
534+ ts . sys ,
535+ tsConfigInfo . tsConfigPath ,
536+ ) ;
534537 }
535538 } catch ( e ) {
536539 // Catch any errors
@@ -549,7 +552,7 @@ ExportMap.parse = function (path, content, context) {
549552 tsConfigCache . set ( cacheKey , tsConfig ) ;
550553 }
551554
552- return tsConfig && tsConfig . compilerOptions ? tsConfig . compilerOptions . esModuleInterop : false ;
555+ return tsConfig && tsConfig . options ? tsConfig . options . esModuleInterop : false ;
553556 }
554557
555558 ast . body . forEach ( function ( n ) {
0 commit comments