Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vue-tsc): support tracing #1402

Merged
merged 2 commits into from Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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