forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.js
48 lines (38 loc) · 1.06 KB
/
run.js
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
const ts = require("typescript");
const path = require("path");
const { reportStatistics } = require("./extended-diagnostics");
let tsconfigPath = path.join(__dirname, "tsconfig.memory.json");
// @ts-ignore
ts.performance.enable();
let host = ts.createWatchCompilerHost(
tsconfigPath,
{
noEmit: true,
noUnusedLocals: true,
noUnusedParameters: true,
allowNonTsExtensions: true,
allowJs: true,
checkJs: true,
extendedDiagnostics: true,
},
ts.sys,
ts.createAbstractBuilder,
() => {},
() => {}
);
host.onUnRecoverableConfigFileDiagnostic = (diagnostic) => {
console.log(
ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine)
);
};
host.trace = () => {};
console.log("TypeScript v" + ts.version);
console.log(
`Memory before: ${Math.trunc(process.memoryUsage().heapUsed / 1048576)} MB`
);
let program = ts.createWatchProgram(host);
console.log(
`Memory after: ${Math.trunc(process.memoryUsage().heapUsed / 1048576)} MB`
);
reportStatistics(ts.sys, program.getProgram().getProgram(), undefined);
program.close();