vue-tsc 2.0.6 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +1 -2
  2. package/index.js +24 -38
  3. package/package.json +4 -4
package/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import type * as ts from 'typescript';
2
1
  export declare function run(): void;
3
- export declare function createFakeGlobalTypesHolder(options: ts.CreateProgramOptions): string | undefined;
2
+ export declare function removeEmitGlobalTypes(dts: string): string;
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFakeGlobalTypesHolder = exports.run = void 0;
3
+ exports.removeEmitGlobalTypes = exports.run = void 0;
4
4
  const runTsc_1 = require("@volar/typescript/lib/quickstart/runTsc");
5
5
  const vue = require("@vue/language-core");
6
6
  const windowsPathReg = /\\/g;
@@ -11,19 +11,31 @@ function run() {
11
11
  const { configFilePath } = options.options;
12
12
  const vueOptions = typeof configFilePath === 'string'
13
13
  ? vue.createParsedCommandLine(ts, ts.sys, configFilePath.replace(windowsPathReg, '/')).vueOptions
14
- : {};
15
- const resolvedVueOptions = vue.resolveVueCompilerOptions(vueOptions);
16
- const { extensions } = resolvedVueOptions;
17
- const fakeGlobalTypesHolder = createFakeGlobalTypesHolder(options);
18
- if (runExtensions.length === extensions.length
19
- && runExtensions.every(ext => extensions.includes(ext))) {
20
- const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id, fileName => fileName === fakeGlobalTypesHolder, options.options, resolvedVueOptions, false);
14
+ : vue.resolveVueCompilerOptions({});
15
+ if (runExtensions.length === vueOptions.extensions.length
16
+ && runExtensions.every(ext => vueOptions.extensions.includes(ext))) {
17
+ const writeFile = options.host.writeFile.bind(options.host);
18
+ options.host.writeFile = (fileName, contents, ...args) => {
19
+ if (fileName.endsWith('.d.ts')
20
+ && vueLanguagePlugin
21
+ .getCanonicalFileName(fileName.replace(windowsPathReg, '/'))
22
+ .slice(0, -5) === vueLanguagePlugin.pluginContext.globalTypesHolder) {
23
+ contents = removeEmitGlobalTypes(contents);
24
+ }
25
+ return writeFile(fileName, contents, ...args);
26
+ };
27
+ const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id, options.host?.useCaseSensitiveFileNames?.() ?? false, () => '', () => options.rootNames.map(rootName => rootName.replace(windowsPathReg, '/')), options.options, vueOptions, false);
21
28
  return [vueLanguagePlugin];
22
29
  }
23
30
  else {
24
- runExtensions = extensions;
31
+ runExtensions = vueOptions.extensions;
25
32
  throw extensionsChangedException;
26
33
  }
34
+ }, fileName => {
35
+ if (runExtensions.some(ext => fileName.endsWith(ext))) {
36
+ return 'vue';
37
+ }
38
+ return vue.resolveCommonLanguageId(fileName);
27
39
  });
28
40
  try {
29
41
  main();
@@ -35,34 +47,8 @@ function run() {
35
47
  }
36
48
  }
37
49
  exports.run = run;
38
- function createFakeGlobalTypesHolder(options) {
39
- const firstVueFile = options.rootNames.find(fileName => fileName.endsWith('.vue'));
40
- if (firstVueFile) {
41
- const fakeFileName = firstVueFile + '__VLS_globalTypes.vue';
42
- options.rootNames.push(fakeFileName);
43
- const fileExists = options.host.fileExists.bind(options.host);
44
- const readFile = options.host.readFile.bind(options.host);
45
- const writeFile = options.host.writeFile.bind(options.host);
46
- options.host.fileExists = fileName => {
47
- if (fileName.endsWith('__VLS_globalTypes.vue')) {
48
- return true;
49
- }
50
- return fileExists(fileName);
51
- };
52
- options.host.readFile = fileName => {
53
- if (fileName.endsWith('__VLS_globalTypes.vue')) {
54
- return '<script setup lang="ts"></script>';
55
- }
56
- return readFile(fileName);
57
- };
58
- options.host.writeFile = (fileName, ...args) => {
59
- if (fileName.endsWith('__VLS_globalTypes.vue.d.ts')) {
60
- return;
61
- }
62
- return writeFile(fileName, ...args);
63
- };
64
- return fakeFileName.replace(windowsPathReg, '/');
65
- }
50
+ function removeEmitGlobalTypes(dts) {
51
+ return dts.replace(/[^\n]*__VLS_globalTypesStart[\w\W]*__VLS_globalTypesEnd[^\n]*\n/, '');
66
52
  }
67
- exports.createFakeGlobalTypesHolder = createFakeGlobalTypesHolder;
53
+ exports.removeEmitGlobalTypes = removeEmitGlobalTypes;
68
54
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "2.0.6",
3
+ "version": "2.0.10",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "bin",
@@ -16,8 +16,8 @@
16
16
  "vue-tsc": "./bin/vue-tsc.js"
17
17
  },
18
18
  "dependencies": {
19
- "@volar/typescript": "~2.1.2",
20
- "@vue/language-core": "2.0.6",
19
+ "@volar/typescript": "~2.2.0-alpha.5",
20
+ "@vue/language-core": "2.0.10",
21
21
  "semver": "^7.5.4"
22
22
  },
23
23
  "peerDependencies": {
@@ -26,5 +26,5 @@
26
26
  "devDependencies": {
27
27
  "@types/node": "latest"
28
28
  },
29
- "gitHead": "feb990ccec85f6330bba37c8b1d1287f0980274c"
29
+ "gitHead": "a20a2ee950b63a949660b7e8faf0faed0e5bad33"
30
30
  }