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(vue-tsc): updated createVueLanguagePlugin syntax, version pin #398

Merged
merged 5 commits into from
Sep 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"@vitejs/plugin-vue": "^5.0.5",
"vite": "^5.3.2",
"vue": "^3.3.4",
"vue-tsc": "^2.0.14"
"vue-tsc": "~2.1.6"
}
}
6 changes: 3 additions & 3 deletions packages/vite-plugin-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@biomejs/biome": "^1.8.3",
"@types/eslint": "^7.2.14",
"@types/fs-extra": "^11.0.1",
"@vue/language-core": "^2.0.14",
"@vue/language-core": "~2.1.6",
"esbuild": "^0.14.27",
"meow": "^9.0.0",
"npm-run-all2": "^5.0.0",
Expand All @@ -64,7 +64,7 @@
"typescript": "^5.5.3",
"vls": "^0.8.5",
"vti": "^0.1.11",
"vue-tsc": "^2.0.14"
"vue-tsc": "~2.1.6"
},
"peerDependencies": {
"@biomejs/biome": ">=1.7",
Expand All @@ -76,7 +76,7 @@
"vite": ">=2.0.0",
"vls": "*",
"vti": "*",
"vue-tsc": ">=2.0.0"
"vue-tsc": "~2.1.6"
},
"peerDependenciesMeta": {
"@biomejs/biome": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
const path = require('node:path')
const { removeEmitGlobalTypes } = require('vue-tsc')

const vueTscDir = path.dirname(require.resolve('vue-tsc/package.json'))
const vue = /** @type {typeof import('@vue/language-core')} */ (
require(require.resolve('@vue/language-core', { paths: [vueTscDir] }))
)
const windowsPathReg = /\\/g

const removeEmitGlobalTypesRegexp = /^[^\n]*__VLS_globalTypesStart[\w\W]*__VLS_globalTypesEnd[^\n]*\n?$/mg;

/**
* @param dts {string}
* @returns {string}
*/
function removeEmitGlobalTypes(dts) {
return dts.replace(removeEmitGlobalTypesRegexp, '');
}

// #region copied from https://github.com/vuejs/language-tools/blob/0781998a29f176ad52c30d3139d5c78a5688bd5d/packages/tsc/index.ts
/**
* @param {typeof import('typescript')} ts
Expand All @@ -29,21 +38,9 @@ exports.getLanguagePlugins = (ts, options) => {
}
const vueLanguagePlugin = vue.createVueLanguagePlugin(
ts,
(id) => id,
() => '',
(fileName) => {
const fileMap = new vue.FileMap(
host?.useCaseSensitiveFileNames?.() ?? false,
)
for (const vueFileName of options.rootNames.map((rootName) =>
rootName.replace(windowsPathReg, '/'),
)) {
fileMap.set(vueFileName, undefined)
}
return fileMap.has(fileName)
},
options.options,
vueOptions,
(id) => id,
)
return [vueLanguagePlugin]
}
Expand Down
6 changes: 3 additions & 3 deletions playground/vue-tsc-vue3/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"private": true,
"name": "@playground/vue-tsc-vue3",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"dev": "vite",
"serve": "vite preview"
},
"dependencies": {
Expand All @@ -16,6 +16,6 @@
"typescript": "^5.5.3",
"vite": "^5.3.2",
"vite-plugin-checker": "workspace:*",
"vue-tsc": "^2.0.14"
"vue-tsc": "~2.1.6"
}
}
91 changes: 51 additions & 40 deletions pnpm-lock.yaml

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