vue-tsc 1.0.9 → 1.0.11

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.
package/bin/vue-tsc.js CHANGED
@@ -6,46 +6,32 @@ const tscPath = require.resolve('typescript/lib/tsc');
6
6
  const proxyPath = require.resolve('../out/proxy');
7
7
 
8
8
  fs.readFileSync = (...args) => {
9
- if (args[0] === tscPath) {
10
- let tsc = readFileSync(...args);
11
-
12
- // add *.vue files to allow extensions
13
- tsc = tsc.replace(
14
- `ts.supportedTSExtensions = [[".ts", ".tsx", ".d.ts"], [".cts", ".d.cts"], [".mts", ".d.mts"]];`,
15
- // `ts.supportedTSExtensions = [[".ts", ".tsx", ".d.ts"], [".cts", ".d.cts"], [".mts", ".d.mts"], [".vue", ".md", ".html"]];`,
16
- `ts.supportedTSExtensions = [[".ts", ".tsx", ".d.ts"], [".cts", ".d.cts"], [".mts", ".d.mts"], [".vue"]];`,
17
- );
18
- tsc = tsc.replace(
19
- `ts.supportedJSExtensions = [[".js", ".jsx"], [".mjs"], [".cjs"]];`,
20
- // `ts.supportedJSExtensions = [[".js", ".jsx"], [".mjs"], [".cjs"], [".vue", ".md", ".html"]];`,
21
- `ts.supportedJSExtensions = [[".js", ".jsx"], [".mjs"], [".cjs"], [".vue"]];`,
22
- );
23
- tsc = tsc.replace(
24
- `var allSupportedExtensions = [[".ts", ".tsx", ".d.ts", ".js", ".jsx"], [".cts", ".d.cts", ".cjs"], [".mts", ".d.mts", ".mjs"]];`,
25
- // `var allSupportedExtensions = [[".ts", ".tsx", ".d.ts", ".js", ".jsx"], [".cts", ".d.cts", ".cjs"], [".mts", ".d.mts", ".mjs"], [".vue", ".md", ".html"]];`,
26
- `var allSupportedExtensions = [[".ts", ".tsx", ".d.ts", ".js", ".jsx"], [".cts", ".d.cts", ".cjs"], [".mts", ".d.mts", ".mjs"], [".vue"]];`,
27
- );
28
-
29
- // proxy createProgram apis
30
- tsc = tsc.replace(
31
- `function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {`,
32
- `function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { return require(${JSON.stringify(proxyPath)}).createProgramProxy(...arguments);`,
33
- );
34
-
35
- // proxy tracing
36
- tsc = tsc.replace(
37
- `ts.startTracing = tracingEnabled.startTracing;`,
38
- `ts.startTracing = require(${JSON.stringify(proxyPath)}).loadTsLib().startTracing;`,
39
- );
40
-
41
- tsc = tsc.replace(
42
- `ts.dumpTracingLegend = tracingEnabled.dumpLegend;`,
43
- `ts.dumpTracingLegend = require(${JSON.stringify(proxyPath)}).loadTsLib().dumpTracingLegend;`,
44
- );
45
-
46
- return tsc;
47
- }
48
- return readFileSync(...args);
9
+ if (args[0] === tscPath) {
10
+ let tsc = readFileSync(...args);
11
+
12
+ // add *.vue files to allow extensions
13
+ tryReplace(/supportedTSExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
14
+ tryReplace(/supportedJSExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
15
+ tryReplace(/allSupportedExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
16
+
17
+ // proxy startTracing, dumpTracingLegend
18
+ tryReplace(/ = tracingEnabled\./g, ` = require(${JSON.stringify(proxyPath)}).loadTsLib().`);
19
+
20
+ // proxy createProgram apis
21
+ tryReplace(/function createProgram\(.+\) {/, s => s + ` return require(${JSON.stringify(proxyPath)}).createProgramProxy(...arguments);`);
22
+
23
+ return tsc;
24
+
25
+ function tryReplace(search, replace) {
26
+ const before = tsc;
27
+ tsc = tsc.replace(search, replace);
28
+ const after = tsc;
29
+ if (after === before) {
30
+ throw 'Search string not found: ' + JSON.stringify(search.toString());
31
+ }
32
+ }
33
+ }
34
+ return readFileSync(...args);
49
35
  };
50
36
 
51
37
  require(tscPath);
package/out/proxy.js CHANGED
@@ -6,9 +6,9 @@ const vueTs = require("@volar/vue-typescript");
6
6
  function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
7
7
  _options, _host, _oldProgram, _configFileParsingDiagnostics) {
8
8
  if (!options.options.noEmit && !options.options.emitDeclarationOnly)
9
- return doThrow('js emit is not support');
9
+ return doThrow('js emit is not supported');
10
10
  if (!options.options.noEmit && options.options.noEmitOnError)
11
- return doThrow('noEmitOnError is not support');
11
+ return doThrow('noEmitOnError is not supported');
12
12
  if (!options.host)
13
13
  return doThrow('!options.host');
14
14
  let program = options.oldProgram;
@@ -49,7 +49,7 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
49
49
  });
50
50
  const vueTsLs = vueTs.createLanguageService(vueLsHost);
51
51
  program = vueTsLs.getProgram();
52
- program.__VLS_ctx = ctx;
52
+ program.__vue = ctx;
53
53
  function getVueCompilerOptions() {
54
54
  const tsConfig = ctx.options.options.configFilePath;
55
55
  if (typeof tsConfig === 'string') {
@@ -91,8 +91,8 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
91
91
  }
92
92
  }
93
93
  else {
94
- program.__VLS_ctx.options = options;
95
- program.__VLS_ctx.projectVersion++;
94
+ program.__vue.options = options;
95
+ program.__vue.projectVersion++;
96
96
  }
97
97
  for (const rootName of options.rootNames) {
98
98
  // register file watchers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "bin",
@@ -16,11 +16,11 @@
16
16
  "vue-tsc": "./bin/vue-tsc.js"
17
17
  },
18
18
  "dependencies": {
19
- "@volar/vue-language-core": "1.0.9",
20
- "@volar/vue-typescript": "1.0.9"
19
+ "@volar/vue-language-core": "1.0.11",
20
+ "@volar/vue-typescript": "1.0.11"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "typescript": "*"
24
24
  },
25
- "gitHead": "be2081f56ce4608324795b8a0ae83c288a3a784d"
25
+ "gitHead": "aff3d7c0896a391412a605597adca7d796e9accf"
26
26
  }