-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsource-map.js
More file actions
27 lines (23 loc) · 729 Bytes
/
source-map.js
File metadata and controls
27 lines (23 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { alterFile, revertFile } from "../lib/utils.js";
export const args = ["--devtool", "source-map"];
export const setup = async () => {
await alterFile("tsconfig.json", (content) => {
if (typeof content !== "string") return content;
try {
const tsconfig = JSON.parse(content);
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
tsconfig.compilerOptions.sourceMap = true;
return JSON.stringify(tsconfig, null, 2) + "\n";
} catch {
// Fallback if JSON parsing fails
return content.replace(
/("compilerOptions"\s*:\s*\{)/,
'$1\n "sourceMap": true,'
);
}
});
};
export const teardown = async () => {
// Restore original tsconfig.json
await revertFile("tsconfig.json");
};