@vue/typescript-plugin 2.1.2 → 2.1.5

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 -5
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
  const createLanguageServicePlugin_1 = require("@volar/typescript/lib/quickstart/createLanguageServicePlugin");
3
+ const path = require("path");
3
4
  const vue = require("@vue/language-core");
4
5
  const common_1 = require("./lib/common");
5
6
  const server_1 = require("./lib/server");
6
7
  const windowsPathReg = /\\/g;
7
8
  const vueCompilerOptions = new WeakMap();
9
+ const setupedProjects = new WeakSet();
8
10
  const basePlugin = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)((ts, info) => {
9
11
  const vueOptions = getVueCompilerOptions();
10
- const languagePlugin = vue.createVueLanguagePlugin(ts, info.languageServiceHost.getCompilationSettings(), vueOptions, id => id);
12
+ const languagePlugin = vue.createVueLanguagePlugin(ts, info.languageServiceHost.getCompilationSettings(), {
13
+ ...vueOptions,
14
+ __setupedGlobalTypes: () => setupedProjects.has(info.project),
15
+ }, id => id);
11
16
  vueCompilerOptions.set(info.project, vueOptions);
12
17
  return {
13
18
  languagePlugins: [languagePlugin],
@@ -44,11 +49,18 @@ const plugin = mods => {
44
49
  const options = vueCompilerOptions.get(proj);
45
50
  if (updateLevel >= 1 && options) {
46
51
  try {
47
- const libDir = require.resolve(`${options.lib}/package.json`, { paths: [proj.getCurrentDirectory()] })
48
- .slice(0, -'package.json'.length);
49
- const globalTypesPath = `${libDir}dist/__globalTypes_${options.target}_${options.strictTemplates}.d.ts`;
50
- const globalTypesContents = vue.generateGlobalTypes(options.lib, options.target, options.strictTemplates);
52
+ let dir = proj.getCurrentDirectory();
53
+ while (!proj.directoryExists(path.resolve(dir, 'node_modules'))) {
54
+ const parentDir = path.resolve(dir, '..');
55
+ if (dir === parentDir) {
56
+ throw 0;
57
+ }
58
+ dir = parentDir;
59
+ }
60
+ const globalTypesPath = path.resolve(dir, `node_modules/.vue-global-types/${options.lib}_${options.target}_${options.strictTemplates}.d.ts`);
61
+ const globalTypesContents = vue.generateGlobalTypes('global', options.lib, options.target, options.strictTemplates);
51
62
  proj.writeFile(globalTypesPath, globalTypesContents);
63
+ setupedProjects.add(proj);
52
64
  }
53
65
  catch { }
54
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/typescript-plugin",
3
- "version": "2.1.2",
3
+ "version": "2.1.5",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -13,11 +13,11 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@volar/typescript": "~2.4.1",
16
- "@vue/language-core": "2.1.2",
16
+ "@vue/language-core": "2.1.5",
17
17
  "@vue/shared": "^3.4.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "latest"
21
21
  },
22
- "gitHead": "4e4b839ea20ae11a2aef7ee9206465cb60a4be53"
22
+ "gitHead": "a95b51ac0b0db8825f77fbba37e29932b5be61e4"
23
23
  }