vue-tsc 2.0.0 → 2.0.1
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/index.d.ts +3 -0
- package/index.js +66 -0
- package/package.json +5 -5
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFakeGlobalTypesHolder = exports.run = void 0;
|
|
4
|
+
const runTsc_1 = require("@volar/typescript/lib/quickstart/runTsc");
|
|
5
|
+
const vue = require("@vue/language-core");
|
|
6
|
+
function run() {
|
|
7
|
+
let runExtensions = ['.vue'];
|
|
8
|
+
const windowsPathReg = /\\/g;
|
|
9
|
+
const extensionsChangedException = new Error('extensions changed');
|
|
10
|
+
const main = () => (0, runTsc_1.runTsc)(require.resolve('typescript/lib/tsc'), runExtensions, (ts, options) => {
|
|
11
|
+
const { configFilePath } = options.options;
|
|
12
|
+
const vueOptions = typeof configFilePath === 'string'
|
|
13
|
+
? vue.createParsedCommandLine(ts, ts.sys, configFilePath.replace(windowsPathReg, '/')).vueOptions
|
|
14
|
+
: {};
|
|
15
|
+
const extensions = vueOptions.extensions ?? ['.vue'];
|
|
16
|
+
if (runExtensions.length === extensions.length
|
|
17
|
+
&& runExtensions.every(ext => extensions.includes(ext))) {
|
|
18
|
+
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id, options.options, vueOptions, false, createFakeGlobalTypesHolder(options)?.replace(windowsPathReg, '/'));
|
|
19
|
+
return [vueLanguagePlugin];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
runExtensions = extensions;
|
|
23
|
+
throw extensionsChangedException;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
main();
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err === extensionsChangedException) {
|
|
31
|
+
main();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.run = run;
|
|
36
|
+
function createFakeGlobalTypesHolder(options) {
|
|
37
|
+
const firstVueFile = options.rootNames.find(fileName => fileName.endsWith('.vue'));
|
|
38
|
+
if (firstVueFile) {
|
|
39
|
+
const fakeFileName = firstVueFile + '__VLS_globalTypes.vue';
|
|
40
|
+
options.rootNames.push(fakeFileName);
|
|
41
|
+
const fileExists = options.host.fileExists.bind(options.host);
|
|
42
|
+
const readFile = options.host.readFile.bind(options.host);
|
|
43
|
+
const writeFile = options.host.writeFile.bind(options.host);
|
|
44
|
+
options.host.fileExists = fileName => {
|
|
45
|
+
if (fileName.endsWith('__VLS_globalTypes.vue')) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return fileExists(fileName);
|
|
49
|
+
};
|
|
50
|
+
options.host.readFile = fileName => {
|
|
51
|
+
if (fileName.endsWith('__VLS_globalTypes.vue')) {
|
|
52
|
+
return '<script setup lang="ts"></script>';
|
|
53
|
+
}
|
|
54
|
+
return readFile(fileName);
|
|
55
|
+
};
|
|
56
|
+
options.host.writeFile = (fileName, ...args) => {
|
|
57
|
+
if (fileName.endsWith('__VLS_globalTypes.vue.d.ts')) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return writeFile(fileName, ...args);
|
|
61
|
+
};
|
|
62
|
+
return fakeFileName;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.createFakeGlobalTypesHolder = createFakeGlobalTypesHolder;
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-tsc",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"bin",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"**/*.js",
|
|
8
|
+
"**/*.d.ts"
|
|
9
9
|
],
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@volar/typescript": "~2.1.0",
|
|
20
|
-
"@vue/language-core": "2.0.
|
|
20
|
+
"@vue/language-core": "2.0.1",
|
|
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": "
|
|
29
|
+
"gitHead": "adedfd0983c910370d080e955702cca7d2275420"
|
|
30
30
|
}
|