vue-tsc 2.0.29 → 2.1.0

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 +14 -12
  3. package/package.json +4 -4
package/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export declare function run(): void;
2
- export declare function removeEmitGlobalTypes(dts: string): string;
1
+ export declare function run(tscPath?: string): void;
package/index.js CHANGED
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.run = run;
4
- exports.removeEmitGlobalTypes = removeEmitGlobalTypes;
5
4
  const runTsc_1 = require("@volar/typescript/lib/quickstart/runTsc");
6
5
  const vue = require("@vue/language-core");
7
6
  const windowsPathReg = /\\/g;
8
- function run() {
7
+ function run(tscPath = require.resolve('typescript/lib/tsc')) {
9
8
  let runExtensions = ['.vue'];
10
9
  const extensionsChangedException = new Error('extensions changed');
11
- const main = () => (0, runTsc_1.runTsc)(require.resolve('typescript/lib/tsc'), runExtensions, (ts, options) => {
10
+ const main = () => (0, runTsc_1.runTsc)(tscPath, runExtensions, (ts, options) => {
12
11
  const { configFilePath } = options.options;
13
12
  const vueOptions = typeof configFilePath === 'string'
14
13
  ? vue.createParsedCommandLine(ts, ts.sys, configFilePath.replace(windowsPathReg, '/')).vueOptions
@@ -16,11 +15,18 @@ function run() {
16
15
  const allExtensions = vue.getAllExtensions(vueOptions);
17
16
  if (runExtensions.length === allExtensions.length
18
17
  && runExtensions.every(ext => allExtensions.includes(ext))) {
19
- const writeFile = options.host.writeFile.bind(options.host);
20
- options.host.writeFile = (fileName, contents, ...args) => {
21
- return writeFile(fileName, removeEmitGlobalTypes(contents), ...args);
22
- };
23
- const vueLanguagePlugin = vue.createVueLanguagePlugin2(ts, id => id, vue.createRootFileChecker(undefined, () => options.rootNames.map(rootName => rootName.replace(windowsPathReg, '/')), options.host?.useCaseSensitiveFileNames?.() ?? false), options.options, vueOptions);
18
+ try {
19
+ const rootDir = typeof configFilePath === 'string'
20
+ ? configFilePath
21
+ : 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);
26
+ ts.sys.writeFile(globalTypesPath, globalTypesContents);
27
+ }
28
+ catch { }
29
+ const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, options.options, vueOptions, id => id);
24
30
  return { languagePlugins: [vueLanguagePlugin] };
25
31
  }
26
32
  else {
@@ -40,8 +46,4 @@ function run() {
40
46
  }
41
47
  }
42
48
  }
43
- const removeEmitGlobalTypesRegexp = /^[^\n]*__VLS_globalTypesStart[\w\W]*__VLS_globalTypesEnd[^\n]*\n?$/mg;
44
- function removeEmitGlobalTypes(dts) {
45
- return dts.replace(removeEmitGlobalTypesRegexp, '');
46
- }
47
49
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "2.0.29",
3
+ "version": "2.1.0",
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.4.0-alpha.18",
20
- "@vue/language-core": "2.0.29",
19
+ "@volar/typescript": "~2.4.1",
20
+ "@vue/language-core": "2.1.0",
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": "49ad9563e6f2677595878a000179dfea83fb910c"
29
+ "gitHead": "510063740b90b64caedaee1f0bde70974613a92c"
30
30
  }