forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsc.ts
More file actions
55 lines (46 loc) · 1.27 KB
/
tsc.ts
File metadata and controls
55 lines (46 loc) · 1.27 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as ts from "./_namespaces/ts";
// This file actually uses arguments passed on commandline and executes it
// enable deprecation logging
ts.Debug.loggingHost = {
log(_level, s) {
ts.sys.write(`${s || ""}${ts.sys.newLine}`);
},
};
interface V8 {
startupSnapshot?: {
isBuildingSnapshot(): boolean;
setDeserializeMainFunction(fn: () => void): void;
};
}
let v8: V8 | undefined;
try {
if (!process.versions.bun) {
v8 = require("v8");
}
}
catch {
// do nothing
}
function main() {
if (ts.Debug.isDebugging) {
ts.Debug.enableDebugInfo();
}
if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
ts.sys.tryEnableSourceMapsForHost();
}
if (ts.sys.setBlocking) {
ts.sys.setBlocking();
}
ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);
}
if (v8?.startupSnapshot?.isBuildingSnapshot()) {
v8.startupSnapshot.setDeserializeMainFunction(() => {
// When we're executed as a snapshot, argv won't contain the js file anymore.
process.argv.splice(1, 0, __filename);
ts.setSys(ts.createSystem());
main();
});
}
else {
main();
}