@volar/typescript 2.4.0-alpha.12 → 2.4.0-alpha.14
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.
|
@@ -4,4 +4,7 @@ export declare let getLanguagePlugins: (ts: typeof import('typescript'), options
|
|
|
4
4
|
languagePlugins: LanguagePlugin<string>[];
|
|
5
5
|
setup?(language: Language<string>): void;
|
|
6
6
|
};
|
|
7
|
-
export declare function runTsc(tscPath: string,
|
|
7
|
+
export declare function runTsc(tscPath: string, options: string[] | {
|
|
8
|
+
extraSupportedExtensions: string[];
|
|
9
|
+
extraExtensionsToRemove: string[];
|
|
10
|
+
}, _getLanguagePlugins: typeof getLanguagePlugins): void;
|
package/lib/quickstart/runTsc.js
CHANGED
|
@@ -5,18 +5,45 @@ exports.runTsc = runTsc;
|
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
let getLanguagePlugins = () => [];
|
|
7
7
|
exports.getLanguagePlugins = getLanguagePlugins;
|
|
8
|
-
function runTsc(tscPath,
|
|
8
|
+
function runTsc(tscPath, options, _getLanguagePlugins) {
|
|
9
9
|
exports.getLanguagePlugins = _getLanguagePlugins;
|
|
10
10
|
const proxyApiPath = require.resolve('../node/proxyCreateProgram');
|
|
11
11
|
const readFileSync = fs.readFileSync;
|
|
12
12
|
fs.readFileSync = (...args) => {
|
|
13
13
|
if (args[0] === tscPath) {
|
|
14
14
|
let tsc = readFileSync(...args);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
let extraSupportedExtensions;
|
|
16
|
+
let extraExtensionsToRemove;
|
|
17
|
+
if (Array.isArray(options)) {
|
|
18
|
+
extraSupportedExtensions = options;
|
|
19
|
+
extraExtensionsToRemove = [];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
extraSupportedExtensions = options.extraSupportedExtensions;
|
|
23
|
+
extraExtensionsToRemove = options.extraExtensionsToRemove;
|
|
24
|
+
}
|
|
25
|
+
const needPatchExtenstions = extraSupportedExtensions.filter(ext => !extraExtensionsToRemove.includes(ext));
|
|
26
|
+
// Add allow extensions
|
|
27
|
+
if (extraSupportedExtensions.length) {
|
|
28
|
+
const extsText = extraSupportedExtensions.map(ext => `"${ext}"`).join(', ');
|
|
29
|
+
tsc = replace(tsc, /supportedTSExtensions = .*(?=;)/, s => s + `.map((group, i) => i === 0 ? group.splice(0, 0, ${extsText}) && group : group)`);
|
|
30
|
+
tsc = replace(tsc, /supportedJSExtensions = .*(?=;)/, s => s + `.map((group, i) => i === 0 ? group.splice(0, 0, ${extsText}) && group : group)`);
|
|
31
|
+
tsc = replace(tsc, /allSupportedExtensions = .*(?=;)/, s => s + `.map((group, i) => i === 0 ? group.splice(0, 0, ${extsText}) && group : group)`);
|
|
32
|
+
}
|
|
33
|
+
// Use to emit basename.xxx to basename.d.ts instead of basename.xxx.d.ts
|
|
34
|
+
if (extraExtensionsToRemove.length) {
|
|
35
|
+
const extsText = extraExtensionsToRemove.map(ext => `"${ext}"`).join(', ');
|
|
36
|
+
tsc = replace(tsc, /extensionsToRemove = .*(?=;)/, s => s + `.concat([${extsText}])`);
|
|
37
|
+
}
|
|
38
|
+
// Support for basename.xxx to basename.xxx.d.ts
|
|
39
|
+
if (needPatchExtenstions.length) {
|
|
40
|
+
const extsText = needPatchExtenstions.map(ext => `"${ext}"`).join(', ');
|
|
41
|
+
tsc = replace(tsc, /function changeExtension\(/, s => `function changeExtension(path, newExtension) {
|
|
42
|
+
return [${extsText}].some(ext => path.endsWith(ext))
|
|
43
|
+
? path + newExtension
|
|
44
|
+
: _changeExtension(path, newExtension)
|
|
45
|
+
}\n` + s.replace('changeExtension', '_changeExtension'));
|
|
46
|
+
}
|
|
20
47
|
// proxy createProgram
|
|
21
48
|
tsc = replace(tsc, /function createProgram\(.+\) {/, s => `var createProgram = require(${JSON.stringify(proxyApiPath)}).proxyCreateProgram(`
|
|
22
49
|
+ [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/typescript",
|
|
3
|
-
"version": "2.4.0-alpha.
|
|
3
|
+
"version": "2.4.0-alpha.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"directory": "packages/typescript"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.4.0-alpha.
|
|
15
|
+
"@volar/language-core": "2.4.0-alpha.14",
|
|
16
16
|
"path-browserify": "^1.0.1",
|
|
17
17
|
"vscode-uri": "^3.0.8"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "latest",
|
|
21
21
|
"@types/path-browserify": "latest",
|
|
22
|
-
"@volar/language-service": "2.4.0-alpha.
|
|
22
|
+
"@volar/language-service": "2.4.0-alpha.14"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "fc61afbf59f54fd6e92776a8569d6ce591e9b9d5"
|
|
25
25
|
}
|