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

fix(tsc): patch build info roots #2580

Merged
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
10 changes: 10 additions & 0 deletions packages/vue-tsc/bin/vue-tsc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node
const semver = require('semver')
const fs = require('fs');
const tsPkg = require('typescript/package.json');
const readFileSync = fs.readFileSync;
const tscPath = require.resolve('typescript/lib/tsc');
const proxyApiPath = require.resolve('../out/index');
Expand All @@ -17,6 +19,14 @@ fs.readFileSync = (...args) => {
// proxy createProgram apis
tryReplace(/function createProgram\(.+\) {/, s => s + ` return require(${JSON.stringify(proxyApiPath)}).createProgram(...arguments);`);

// patches logic for checking root file existance in build program for incremental builds
if (semver.gt(tsPkg.version, '5.0.0')) {
tryReplace(`for (const existingRoot of buildInfoVersionMap.roots) {`, `for (const existingRoot of buildInfoVersionMap.roots
.filter(file => !file.toLowerCase().includes('__vls_'))
.map(file => file.replace(/\.vue\.(j|t)sx?$/i, '.vue'))
) {`);
}

return tsc;

function tryReplace(search, replace) {
Expand Down
3 changes: 2 additions & 1 deletion packages/vue-tsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"dependencies": {
"@volar/vue-language-core": "1.3.12",
"@volar/vue-typescript": "1.3.12"
"@volar/vue-typescript": "1.3.12",
"semver": "^7.3.8"
},
"peerDependencies": {
"typescript": "*"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.