From 9f7e5149faa4ddb15d667610ad0976c65aeaafbe Mon Sep 17 00:00:00 2001 From: Roman Batsenko Date: Mon, 24 Jun 2024 14:56:09 +0200 Subject: [PATCH] chore: parse tsconfig.json with built-in ts helper --- src/compileTypes/helpers/getTSConfigCompilerOptions.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compileTypes/helpers/getTSConfigCompilerOptions.ts b/src/compileTypes/helpers/getTSConfigCompilerOptions.ts index aaa5798..31aff2c 100644 --- a/src/compileTypes/helpers/getTSConfigCompilerOptions.ts +++ b/src/compileTypes/helpers/getTSConfigCompilerOptions.ts @@ -13,5 +13,12 @@ export function getTSConfigCompilerOptions(tsconfigFileNameOrPath: string): ts.C process.exit(1); } - return require(tsconfigPath).compilerOptions; + const tsconfigJsonFile = ts.readJsonConfigFile(tsconfigPath, ts.sys.readFile); + const parsedConfig = ts.parseJsonSourceFileConfigFileContent( + tsconfigJsonFile, + ts.sys, + path.dirname(tsconfigPath), + ); + + return parsedConfig.options; }