diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 4a8d7dd3..3277a2c9 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -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" } } diff --git a/packages/vite-plugin-checker/package.json b/packages/vite-plugin-checker/package.json index f631ee09..531a9dbf 100644 --- a/packages/vite-plugin-checker/package.json +++ b/packages/vite-plugin-checker/package.json @@ -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", @@ -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", @@ -76,7 +76,7 @@ "vite": ">=2.0.0", "vls": "*", "vti": "*", - "vue-tsc": ">=2.0.0" + "vue-tsc": "~2.1.6" }, "peerDependenciesMeta": { "@biomejs/biome": { diff --git a/packages/vite-plugin-checker/src/checkers/vueTsc/languagePlugins.cjs b/packages/vite-plugin-checker/src/checkers/vueTsc/languagePlugins.cjs index 898b0363..b02a426d 100644 --- a/packages/vite-plugin-checker/src/checkers/vueTsc/languagePlugins.cjs +++ b/packages/vite-plugin-checker/src/checkers/vueTsc/languagePlugins.cjs @@ -1,5 +1,4 @@ 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')} */ ( @@ -7,6 +6,16 @@ const vue = /** @type {typeof import('@vue/language-core')} */ ( ) 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 @@ -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] } diff --git a/playground/vue-tsc-vue3/package.json b/playground/vue-tsc-vue3/package.json index bbb21a3f..d9d25ddd 100644 --- a/playground/vue-tsc-vue3/package.json +++ b/playground/vue-tsc-vue3/package.json @@ -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": { @@ -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" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b802d7ed..c036e22d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -155,8 +155,8 @@ importers: specifier: ^3.3.4 version: 3.4.29(typescript@5.5.3) vue-tsc: - specifier: ^2.0.14 - version: 2.0.21(typescript@5.5.3) + specifier: ~2.1.6 + version: 2.1.6(typescript@5.5.3) packages/vite-plugin-checker: dependencies: @@ -213,8 +213,8 @@ importers: specifier: ^11.0.1 version: 11.0.4 '@vue/language-core': - specifier: ^2.0.14 - version: 2.0.21(typescript@5.5.3) + specifier: ~2.1.6 + version: 2.1.6(typescript@5.5.3) esbuild: specifier: ^0.14.27 version: 0.14.54 @@ -240,8 +240,8 @@ importers: specifier: ^0.1.11 version: 0.1.11 vue-tsc: - specifier: ^2.0.14 - version: 2.0.21(typescript@5.5.3) + specifier: ~2.1.6 + version: 2.1.6(typescript@5.5.3) playground/backend-integration: dependencies: @@ -898,7 +898,7 @@ importers: version: 0.12.2(vite@5.3.2(@types/node@15.14.9)(sass@1.77.6)) vite-plugin-vue2: specifier: ^1.9.0 - version: 1.9.3(lodash@4.17.21)(vite@5.3.2(@types/node@15.14.9)(sass@1.77.6))(vue-template-compiler@2.7.16)(vue@2.7.16) + version: 1.9.3(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(vite@5.3.2(@types/node@15.14.9)(sass@1.77.6))(vue-template-compiler@2.7.16)(vue@2.7.16) vls: specifier: ^0.8.5 version: 0.8.5 @@ -928,8 +928,8 @@ importers: specifier: workspace:* version: link:../../packages/vite-plugin-checker vue-tsc: - specifier: ^2.0.14 - version: 2.0.21(typescript@5.5.3) + specifier: ~2.1.6 + version: 2.1.6(typescript@5.5.3) packages: @@ -2094,14 +2094,14 @@ packages: '@vitest/utils@1.6.0': resolution: {integrity: sha512-21cPiuGMoMZwiOHa2i4LXkMkMkCGzA+MVFV70jRwHo95dL4x/ts5GZhML1QWuy7yfp3WzK3lRvZi3JnXTYqrBw==} - '@volar/language-core@2.3.0': - resolution: {integrity: sha512-pvhL24WUh3VDnv7Yw5N1sjhPtdx7q9g+Wl3tggmnkMcyK8GcCNElF2zHiKznryn0DiUGk+eez/p2qQhz+puuHw==} + '@volar/language-core@2.4.1': + resolution: {integrity: sha512-9AKhC7Qn2mQYxj7Dz3bVxeOk7gGJladhWixUYKef/o0o7Bm4an+A3XvmcTHVqZ8stE6lBVH++g050tBtJ4TZPQ==} - '@volar/source-map@2.3.0': - resolution: {integrity: sha512-G/228aZjAOGhDjhlyZ++nDbKrS9uk+5DMaEstjvzglaAw7nqtDyhnQAsYzUg6BMP9BtwZ59RIw5HGePrutn00Q==} + '@volar/source-map@2.4.1': + resolution: {integrity: sha512-Xq6ep3OZg9xUqN90jEgB9ztX5SsTz1yiV8wiQbcYNjWkek+Ie3dc8l7AVt3EhDm9mSIR58oWczHkzM2H6HIsmQ==} - '@volar/typescript@2.3.0': - resolution: {integrity: sha512-PtUwMM87WsKVeLJN33GSTUjBexlKfKgouWlOUIv7pjrOnTwhXHZNSmpc312xgXdTjQPpToK6KXSIcKu9sBQ5LQ==} + '@volar/typescript@2.4.1': + resolution: {integrity: sha512-UoRzC0PXcwajFQTu8XxKSYNsWNBtVja6Y9gC8eLv7kYm+UEKJCcZ8g7dialsOYA0HKs3Vpg57MeCsawFLC6m9Q==} '@vue/babel-helper-vue-jsx-merge-props@1.4.0': resolution: {integrity: sha512-JkqXfCkUDp4PIlFdDQ0TdXoIejMtTHP67/pvxlgeY+u5k3LEdKuWZ3LK6xkxo52uDoABIVyRwqVkfLQJhk7VBA==} @@ -2165,6 +2165,9 @@ packages: '@vue/compiler-ssr@3.4.29': resolution: {integrity: sha512-rFbwCmxJ16tDp3N8XCx5xSQzjhidYjXllvEcqX/lopkoznlNPz3jyy0WGJCyhAaVQK677WWFt3YO/WUEkMMUFQ==} + '@vue/compiler-vue2@2.7.16': + resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} + '@vue/component-compiler-utils@3.3.0': resolution: {integrity: sha512-97sfH2mYNU+2PzGrmK2haqffDpVASuib9/w2/noxiFi31Z54hW+q3izKQXXQZSNhtiUpAI36uSuYepeBe4wpHQ==} @@ -2197,8 +2200,8 @@ packages: typescript: optional: true - '@vue/language-core@2.0.21': - resolution: {integrity: sha512-vjs6KwnCK++kIXT+eI63BGpJHfHNVJcUCr3RnvJsccT3vbJnZV5IhHR2puEkoOkIbDdp0Gqi1wEnv3hEd3WsxQ==} + '@vue/language-core@2.1.6': + resolution: {integrity: sha512-MW569cSky9R/ooKMh6xa2g1D0AtRKbL56k83dzus/bx//RDJk24RHWkMzbAlXjMdDNyxAaagKPRquBIxkxlCkg==} peerDependencies: typescript: '*' peerDependenciesMeta: @@ -5179,11 +5182,11 @@ packages: vue-template-es2015-compiler@1.9.1: resolution: {integrity: sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==} - vue-tsc@2.0.21: - resolution: {integrity: sha512-E6x1p1HaHES6Doy8pqtm7kQern79zRtIewkf9fiv7Y43Zo4AFDS5hKi+iHi2RwEhqRmuiwliB1LCEFEGwvxQnw==} + vue-tsc@2.1.6: + resolution: {integrity: sha512-f98dyZp5FOukcYmbFpuSCJ4Z0vHSOSmxGttZJCsFeX0M4w/Rsq0s4uKXjcSRsZqsRgQa6z7SfuO+y0HVICE57Q==} hasBin: true peerDependencies: - typescript: '*' + typescript: '>=5.0.0' vue@2.7.16: resolution: {integrity: sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==} @@ -6609,17 +6612,15 @@ snapshots: loupe: 2.3.7 pretty-format: 29.7.0 - '@volar/language-core@2.3.0': + '@volar/language-core@2.4.1': dependencies: - '@volar/source-map': 2.3.0 + '@volar/source-map': 2.4.1 - '@volar/source-map@2.3.0': - dependencies: - muggle-string: 0.4.1 + '@volar/source-map@2.4.1': {} - '@volar/typescript@2.3.0': + '@volar/typescript@2.4.1': dependencies: - '@volar/language-core': 2.3.0 + '@volar/language-core': 2.4.1 path-browserify: 1.0.1 vscode-uri: 3.0.8 @@ -6732,9 +6733,14 @@ snapshots: '@vue/compiler-dom': 3.4.29 '@vue/shared': 3.4.29 - '@vue/component-compiler-utils@3.3.0(lodash@4.17.21)': + '@vue/compiler-vue2@2.7.16': + dependencies: + de-indent: 1.0.2 + he: 1.2.0 + + '@vue/component-compiler-utils@3.3.0(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: - consolidate: 0.15.1(lodash@4.17.21) + consolidate: 0.15.1(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) hash-sum: 1.0.2 lru-cache: 4.1.5 merge-source-map: 1.1.0 @@ -6836,15 +6842,16 @@ snapshots: transitivePeerDependencies: - supports-color - '@vue/language-core@2.0.21(typescript@5.5.3)': + '@vue/language-core@2.1.6(typescript@5.5.3)': dependencies: - '@volar/language-core': 2.3.0 + '@volar/language-core': 2.4.1 '@vue/compiler-dom': 3.4.29 + '@vue/compiler-vue2': 2.7.16 '@vue/shared': 3.4.29 computeds: 0.0.1 minimatch: 9.0.4 + muggle-string: 0.4.1 path-browserify: 1.0.1 - vue-template-compiler: 2.7.16 optionalDependencies: typescript: 5.5.3 @@ -7211,17 +7218,21 @@ snapshots: confbox@0.1.7: {} - consolidate@0.15.1(lodash@4.17.21): + consolidate@0.15.1(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: bluebird: 3.7.2 optionalDependencies: lodash: 4.17.21 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) - consolidate@0.16.0(lodash@4.17.21): + consolidate@0.16.0(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: bluebird: 3.7.2 optionalDependencies: lodash: 4.17.21 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) content-disposition@0.5.4: dependencies: @@ -9352,7 +9363,7 @@ snapshots: transitivePeerDependencies: - supports-color - vite-plugin-vue2@1.9.3(lodash@4.17.21)(vite@5.3.2(@types/node@15.14.9)(sass@1.77.6))(vue-template-compiler@2.7.16)(vue@2.7.16): + vite-plugin-vue2@1.9.3(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(vite@5.3.2(@types/node@15.14.9)(sass@1.77.6))(vue-template-compiler@2.7.16)(vue@2.7.16): dependencies: '@babel/core': 7.24.7 '@babel/parser': 7.24.7 @@ -9362,8 +9373,8 @@ snapshots: '@rollup/pluginutils': 4.2.1 '@vue/babel-helper-vue-jsx-merge-props': 1.4.0 '@vue/babel-preset-jsx': 1.4.0(@babel/core@7.24.7)(vue@2.7.16) - '@vue/component-compiler-utils': 3.3.0(lodash@4.17.21) - consolidate: 0.16.0(lodash@4.17.21) + '@vue/component-compiler-utils': 3.3.0(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + consolidate: 0.16.0(lodash@4.17.21)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) debug: 4.3.5(supports-color@8.1.1) fs-extra: 9.1.0 hash-sum: 2.0.0 @@ -9634,10 +9645,10 @@ snapshots: vue-template-es2015-compiler@1.9.1: {} - vue-tsc@2.0.21(typescript@5.5.3): + vue-tsc@2.1.6(typescript@5.5.3): dependencies: - '@volar/typescript': 2.3.0 - '@vue/language-core': 2.0.21(typescript@5.5.3) + '@volar/typescript': 2.4.1 + '@vue/language-core': 2.1.6(typescript@5.5.3) semver: 7.6.2 typescript: 5.5.3