Skip to content

Commit

Permalink
feat(vue-tsc): support tracing (#1402)
Browse files Browse the repository at this point in the history
Co-authored-by: johnsoncodehk <johnsoncodehk@gmail.com>
  • Loading branch information
blake-newman and johnsoncodehk committed Jun 6, 2022
1 parent c0fb86c commit 0759a5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/vue-tsc/bin/vue-tsc.js
Expand Up @@ -32,6 +32,18 @@ fs.readFileSync = (...args) => {
`function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {`,
`function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { return require(${JSON.stringify(proxyPath)}).createProgramProxy(...arguments);`,
);

// proxy tracing
tsc = tsc.replace(
`ts.startTracing = tracingEnabled.startTracing;`,
`ts.startTracing = require(${JSON.stringify(proxyPath)}).loadTsLib().startTracing;`,
);

tsc = tsc.replace(
`ts.dumpTracingLegend = tracingEnabled.dumpLegend;`,
`ts.dumpTracingLegend = require(${JSON.stringify(proxyPath)}).loadTsLib().dumpTracingLegend;`,
);

return tsc;
}
return readFileSync(...args);
Expand Down
4 changes: 4 additions & 0 deletions packages/vue-tsc/src/proxy.ts
Expand Up @@ -119,6 +119,10 @@ export function createProgramProxy(
}
}

export function loadTsLib() {
return ts;
}

function doThrow(msg: string) {
console.error(msg);
throw msg;
Expand Down

0 comments on commit 0759a5c

Please sign in to comment.