Comparing version 1.6.5 to 1.8.24
@@ -24,7 +24,22 @@ #!/usr/bin/env node | ||
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')) | ||
) {`); | ||
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')) | ||
) {` | ||
); | ||
tryReplace( | ||
`return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];`, | ||
`return [toFileId(key), toFileIdListId(new Set(arrayFrom(state.exportedModulesMap.getValues(key)).filter(file => file !== void 0)))];` | ||
); | ||
} | ||
if (semver.gte(tsPkg.version, '5.0.4')) { | ||
tryReplace( | ||
`return createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, host);`, | ||
s => `buildInfo.program.fileNames = buildInfo.program.fileNames | ||
.filter(file => !file.toLowerCase().includes('__vls_')) | ||
.map(file => file.replace(/\.vue\.(j|t)sx?$/i, '.vue'));\n` + s | ||
); | ||
} | ||
@@ -31,0 +46,0 @@ return tsc; |
@@ -1,4 +0,3 @@ | ||
import * as ts from 'typescript'; | ||
import * as vue from '@volar/vue-language-core'; | ||
import * as vueTs from '@volar/vue-typescript'; | ||
import type * as ts from 'typescript/lib/tsserverlibrary'; | ||
import * as vue from '@vue/language-core'; | ||
export type Hook = (program: _Program) => void; | ||
@@ -11,6 +10,9 @@ export type _Program = ts.Program & { | ||
options: ts.CreateProgramOptions; | ||
languageServiceHost: vue.VueLanguageServiceHost; | ||
languageService: ReturnType<typeof vueTs.createLanguageService>; | ||
languageHost: vue.TypeScriptLanguageHost; | ||
vueCompilerOptions: Partial<vue.VueCompilerOptions>; | ||
langaugeContext: vue.LanguageContext; | ||
languageService: ts.LanguageService; | ||
} | ||
export declare function createProgram(options: ts.CreateProgramOptions): _Program; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createProgram = void 0; | ||
const ts = require("typescript"); | ||
const vue = require("@volar/vue-language-core"); | ||
const vueTs = require("@volar/vue-typescript"); | ||
const vue = require("@vue/language-core"); | ||
const volarTs = require("@volar/typescript"); | ||
const shared_1 = require("./shared"); | ||
const windowsPathReg = /\\/g; | ||
function createProgram(options) { | ||
@@ -17,2 +17,3 @@ if (!options.options.noEmit && !options.options.emitDeclarationOnly) | ||
throw toThrow('!options.host'); | ||
const ts = require('typescript'); | ||
let program = options.oldProgram; | ||
@@ -27,26 +28,24 @@ if (shared_1.state.hook) { | ||
options, | ||
get languageServiceHost() { | ||
return vueLsHost; | ||
get languageHost() { | ||
return languageHost; | ||
}, | ||
get vueCompilerOptions() { | ||
return vueCompilerOptions; | ||
}, | ||
get languageService() { | ||
return vueTsLs; | ||
}, | ||
get langaugeContext() { | ||
return languageContext; | ||
}, | ||
}; | ||
const vueCompilerOptions = getVueCompilerOptions(); | ||
const scripts = new Map(); | ||
const vueLsHost = new Proxy({ | ||
// avoid failed with tsc built-in fileExists | ||
resolveModuleNames: undefined, | ||
resolveModuleNameLiterals: undefined, | ||
writeFile: (fileName, content) => { | ||
if (fileName.indexOf('__VLS_') === -1) { | ||
ctx.options.host.writeFile(fileName, content, false); | ||
} | ||
}, | ||
const languageHost = { | ||
workspacePath: ctx.options.host.getCurrentDirectory().replace(windowsPathReg, '/'), | ||
rootPath: ctx.options.host.getCurrentDirectory().replace(windowsPathReg, '/'), | ||
getCompilationSettings: () => ctx.options.options, | ||
getVueCompilationSettings: () => vueCompilerOptions, | ||
getScriptFileNames: () => { | ||
return ctx.options.rootNames; | ||
}, | ||
getScriptVersion, | ||
getScriptSnapshot, | ||
@@ -57,13 +56,9 @@ getProjectVersion: () => { | ||
getProjectReferences: () => ctx.options.projectReferences, | ||
isTsc: true, | ||
}, { | ||
get: (target, property) => { | ||
if (property in target) { | ||
return target[property]; | ||
} | ||
return ctx.options.host[property]; | ||
}, | ||
}); | ||
const vueTsLs = vueTs.createLanguageService(vueLsHost); | ||
program = vueTsLs.getProgram(); | ||
getCancellationToken: ctx.options.host.getCancellationToken ? () => ctx.options.host.getCancellationToken() : undefined, | ||
}; | ||
const languageContext = vue.createLanguageContext(languageHost, vue.createLanguages(ts, languageHost.getCompilationSettings(), vueCompilerOptions)); | ||
const languageServiceHost = volarTs.createLanguageServiceHost(languageContext, ts, ts.sys); | ||
const vueTsLs = ts.createLanguageService(languageServiceHost, volarTs.getDocumentRegistry(ts, ts.sys.useCaseSensitiveFileNames, languageHost.workspacePath)); | ||
volarTs.decorateLanguageService(languageContext.virtualFiles, vueTsLs, false); | ||
program = volarTs.getProgram(ts, languageContext, vueTsLs, ts.sys); | ||
program.__vue = ctx; | ||
@@ -73,9 +68,6 @@ function getVueCompilerOptions() { | ||
if (typeof tsConfig === 'string') { | ||
return vue.createParsedCommandLine(ts, ts.sys, tsConfig, []).vueOptions; | ||
return vue.createParsedCommandLine(ts, ts.sys, tsConfig.replace(windowsPathReg, '/')).vueOptions; | ||
} | ||
return {}; | ||
} | ||
function getScriptVersion(fileName) { | ||
return getScript(fileName)?.version ?? ''; | ||
} | ||
function getScriptSnapshot(fileName) { | ||
@@ -113,4 +105,4 @@ return getScript(fileName)?.scriptSnapshot; | ||
} | ||
const vueCompilerOptions = program.__vue.languageServiceHost.getVueCompilationSettings(); | ||
if (vueCompilerOptions.hooks) { | ||
const vueCompilerOptions = program.__vue.vueCompilerOptions; | ||
if (vueCompilerOptions?.hooks) { | ||
const index = (shared_1.state.hook?.index ?? -1) + 1; | ||
@@ -117,0 +109,0 @@ if (index < vueCompilerOptions.hooks.length) { |
@@ -9,1 +9,2 @@ import type { _Program } from './index'; | ||
}; | ||
//# sourceMappingURL=shared.d.ts.map |
{ | ||
"name": "vue-tsc", | ||
"version": "1.6.5", | ||
"version": "1.8.24", | ||
"main": "out/index.js", | ||
@@ -14,3 +14,3 @@ "license": "MIT", | ||
"url": "https://github.com/vuejs/language-tools.git", | ||
"directory": "packages/vue-tsc" | ||
"directory": "packages/tsc" | ||
}, | ||
@@ -21,5 +21,5 @@ "bin": { | ||
"dependencies": { | ||
"@volar/vue-language-core": "1.6.5", | ||
"@volar/vue-typescript": "1.6.5", | ||
"semver": "^7.3.8" | ||
"@volar/typescript": "~1.11.1", | ||
"@vue/language-core": "1.8.24", | ||
"semver": "^7.5.4" | ||
}, | ||
@@ -29,3 +29,6 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "d9f0c995e254bd0a3acf910c6a766aabd56792a7" | ||
"devDependencies": { | ||
"@types/node": "latest" | ||
}, | ||
"gitHead": "6f850196d6b9cd1bee62104d3d92867cf0b6777e" | ||
} |
@@ -7,3 +7,3 @@ # vue-tsc | ||
Vue 3 command line Type-Checking tool base on IDE plugin [Volar](https://github.com/johnsoncodehk/volar). | ||
Vue 3 command line Type-Checking tool base on IDE plugin [Volar](https://github.com/vuejs/language-tools). | ||
@@ -29,3 +29,3 @@ Roadmap: | ||
Check out https://github.com/johnsoncodehk/volar/discussions/640#discussioncomment-1555479 for example repo. | ||
Check out https://github.com/vuejs/language-tools/discussions/640#discussioncomment-1555479 for example repo. | ||
@@ -32,0 +32,0 @@ ## Sponsors |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11349
217
1
+ Added@volar/typescript@~1.11.1
+ Added@vue/language-core@1.8.24
+ Added@volar/language-core@1.11.1(transitive)
+ Added@volar/source-map@1.11.1(transitive)
+ Added@volar/typescript@1.11.1(transitive)
+ Added@vue/language-core@1.8.24(transitive)
+ Addedcomputeds@0.0.1(transitive)
+ Addedmuggle-string@0.3.1(transitive)
+ Addedpath-browserify@1.0.1(transitive)
- Removed@volar/vue-language-core@1.6.5
- Removed@volar/vue-typescript@1.6.5
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@volar/language-core@1.4.1(transitive)
- Removed@volar/source-map@1.4.1(transitive)
- Removed@volar/typescript@1.4.1-patch.2(transitive)
- Removed@volar/vue-language-core@1.6.5(transitive)
- Removed@volar/vue-typescript@1.6.5(transitive)
- Removed@vue/compiler-sfc@3.5.12(transitive)
- Removed@vue/compiler-ssr@3.5.12(transitive)
- Removed@vue/reactivity@3.5.12(transitive)
- Removedmagic-string@0.30.12(transitive)
- Removedmuggle-string@0.2.2(transitive)
- Removednanoid@3.3.7(transitive)
- Removedpicocolors@1.1.0(transitive)
- Removedpostcss@8.4.47(transitive)
Updatedsemver@^7.5.4