Skip to content

Commit e9c0f7b

Browse files
Enable sourceMap in tsconfig with error handling
Added error handling and logging for tsconfig update.
1 parent 318c424 commit e9c0f7b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/setup-build.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ const { readFileSync, writeFileSync } = require("node:fs");
22
const { resolve } = require("node:path");
33

44
const tsConfigPath = resolve(__dirname, "../tsconfig.json");
5-
const tsConfigRaw = readFileSync(tsConfigPath);
6-
const tsConfig = JSON.parse(tsConfigRaw);
75

8-
tsConfig.compilerOptions.sourceMap = true;
6+
try {
7+
const tsConfigRaw = readFileSync(tsConfigPath, "utf-8");
8+
const tsConfig = JSON.parse(tsConfigRaw);
99

10-
writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2));
10+
tsConfig.compilerOptions = tsConfig.compilerOptions || {};
11+
tsConfig.compilerOptions.sourceMap = true;
12+
13+
writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2), "utf-8");
14+
console.log("tsconfig.json updated successfully with sourceMap enabled.");
15+
} catch (error) {
16+
console.error("Failed to update tsconfig.json:", error.message);
17+
}

0 commit comments

Comments
 (0)