Skip to content

Commit

Permalink
build: remove plugin vue-tsc dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Sep 8, 2024
1 parent b76fe5e commit b6d8981
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
3 changes: 2 additions & 1 deletion examples/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@vitejs/plugin-vue-jsx": "^3.1.0",
"tslib": "^2.6.2",
"typescript": "5.5.4",
"vite": "^5.3.4"
"vite": "^5.3.4",
"vue-tsc": "^2.1.6"
},
"auth": "qmhc"
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@
"url": "https://github.com/qmhc/vite-plugin-dts/issues"
},
"dependencies": {
"@microsoft/api-extractor": "7.47.4",
"@microsoft/api-extractor": "7.47.7",
"@rollup/pluginutils": "^5.1.0",
"@volar/typescript": "^2.4.4",
"@vue/language-core": "2.1.6",
"compare-versions": "^6.1.1",
"debug": "^4.3.6",
"kolorist": "^1.8.0",
"local-pkg": "^0.5.0",
"magic-string": "^0.30.11",
"vue-tsc": "2.0.29"
"magic-string": "^0.30.11"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
Expand Down
16 changes: 7 additions & 9 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {

import { proxyCreateProgram } from '@volar/typescript'
import ts from 'typescript'
import { removeEmitGlobalTypes } from 'vue-tsc'
import { tryGetPackageInfo } from './utils'

export { createParsedCommandLine }
Expand All @@ -24,13 +23,6 @@ const _createProgram = !hasVue
? createParsedCommandLine(ts, ts.sys, configFilePath.replace(/\\/g, '/')).vueOptions
: resolveVueCompilerOptions({})

if (options.host) {
const writeFile = options.host.writeFile.bind(options.host)
options.host.writeFile = (fileName, contents, ...args) => {
return writeFile(fileName, removeEmitGlobalTypes(contents), ...args)
}
}

const vueLanguagePlugin = createVueLanguagePlugin<string>(
ts,
options.options,
Expand Down Expand Up @@ -58,7 +50,7 @@ export const createProgram = !hasVue
targetSourceFile,
(fileName, data, writeByteOrderMark, onError, sourceFiles) => {
if (fileName.endsWith('.d.ts')) {
data = removeEmitGlobalTypes(data)
// data = removeVolarGlobalTypes(data)
}
return writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)
},
Expand All @@ -79,3 +71,9 @@ export const createProgram = !hasVue

return program
}

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

// export function removeVolarGlobalTypes(dts: string) {
// return dts.replace(removeVolarGlobalTypesRegexp, '')
// }
3 changes: 1 addition & 2 deletions src/resolvers/vue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { removeEmitGlobalTypes } from 'vue-tsc'
import { base64VLQEncode } from '../utils'

import type { Resolver } from '../types'
Expand Down Expand Up @@ -31,7 +30,7 @@ export function VueResolver(): Resolver {
program.emit(
sourceFile,
(path, content) => {
outputs.push({ path, content: removeEmitGlobalTypes(content) })
outputs.push({ path, content })
},
undefined,
true
Expand Down

0 comments on commit b6d8981

Please sign in to comment.