vue-tsc 2.1.0 → 2.1.4

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 (2) hide show
  1. package/index.js +17 -6
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.run = run;
4
4
  const runTsc_1 = require("@volar/typescript/lib/quickstart/runTsc");
5
+ const path = require("path");
5
6
  const vue = require("@vue/language-core");
6
7
  const windowsPathReg = /\\/g;
7
8
  function run(tscPath = require.resolve('typescript/lib/tsc')) {
@@ -15,18 +16,28 @@ function run(tscPath = require.resolve('typescript/lib/tsc')) {
15
16
  const allExtensions = vue.getAllExtensions(vueOptions);
16
17
  if (runExtensions.length === allExtensions.length
17
18
  && runExtensions.every(ext => allExtensions.includes(ext))) {
19
+ let setupedGlobalTypes = false;
18
20
  try {
19
- const rootDir = typeof configFilePath === 'string'
21
+ let dir = typeof configFilePath === 'string'
20
22
  ? configFilePath
21
23
  : options.host?.getCurrentDirectory() ?? ts.sys.getCurrentDirectory();
22
- const libDir = require.resolve(`${vueOptions.lib}/package.json`, { paths: [rootDir] })
23
- .slice(0, -'package.json'.length);
24
- const globalTypesPath = `${libDir}__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`;
25
- const globalTypesContents = vue.generateGlobalTypes(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
24
+ while (!ts.sys.directoryExists(path.resolve(dir, 'node_modules'))) {
25
+ const parentDir = path.resolve(dir, '..');
26
+ if (dir === parentDir) {
27
+ throw 0;
28
+ }
29
+ dir = parentDir;
30
+ }
31
+ const globalTypesPath = path.resolve(dir, `node_modules/.vue-global-types/${vueOptions.lib}_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`);
32
+ const globalTypesContents = vue.generateGlobalTypes('global', vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
26
33
  ts.sys.writeFile(globalTypesPath, globalTypesContents);
34
+ setupedGlobalTypes = true;
27
35
  }
28
36
  catch { }
29
- const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, options.options, vueOptions, id => id);
37
+ const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, options.options, {
38
+ ...vueOptions,
39
+ __setupedGlobalTypes: () => setupedGlobalTypes,
40
+ }, id => id);
30
41
  return { languagePlugins: [vueLanguagePlugin] };
31
42
  }
32
43
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "2.1.0",
3
+ "version": "2.1.4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "bin",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@volar/typescript": "~2.4.1",
20
- "@vue/language-core": "2.1.0",
20
+ "@vue/language-core": "2.1.4",
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": "510063740b90b64caedaee1f0bde70974613a92c"
29
+ "gitHead": "5e197d08eaef57209ff2927c943ba1db3bf4eff6"
30
30
  }