From 738ff0039e587462ba104573f6cca8528012f6f9 Mon Sep 17 00:00:00 2001 From: Wout Mertens Date: Thu, 14 Jul 2022 02:38:21 +0200 Subject: [PATCH] nodejs: improve tsconfig patcher --- .../builders/granular/tsconfig-to-json.js | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/subsystems/nodejs/builders/granular/tsconfig-to-json.js b/src/subsystems/nodejs/builders/granular/tsconfig-to-json.js index 1ccd3db042..c67956b245 100644 --- a/src/subsystems/nodejs/builders/granular/tsconfig-to-json.js +++ b/src/subsystems/nodejs/builders/granular/tsconfig-to-json.js @@ -1,19 +1,21 @@ try { - console.log(require.resolve("typescript")); -} catch(e) { - console.error("typescript is not found"); - process.exit(e.code); + require.resolve("typescript"); +} catch (e) { + process.exit(0); } -const ts = require("typescript") -const fs = require('fs') +const ts = require("typescript"); +const fs = require("fs"); try { - const data = fs.readFileSync('tsconfig.json', 'utf8') + const data = fs.readFileSync("tsconfig.json", "utf8"); } catch (err) { - console.error(err) + console.error(err); } -config = ts.parseConfigFileTextToJson(data) -newdata = JSON.stringify(config) -fs.writeFileSync('tsconfig.json', newdata); +config = ts.parseConfigFileTextToJson(data); + +// https://www.typescriptlang.org/tsconfig#preserveSymlinks +config.compilerOptions.preserveSymlinks = true; + +fs.writeFileSync("tsconfig.json", JSON.stringify(config));