@volar/typescript 2.0.0-alpha.4 → 2.0.0-alpha.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.
|
@@ -8,9 +8,6 @@ function proxyCreateProgram(ts, original, extensions, getLanguagePlugins) {
|
|
|
8
8
|
apply: (target, thisArg, args) => {
|
|
9
9
|
const options = args[0];
|
|
10
10
|
assert(!!options.host, '!!options.host');
|
|
11
|
-
const originalHost = options.host;
|
|
12
|
-
options.host = { ...originalHost };
|
|
13
|
-
options.options.allowArbitraryExtensions = true;
|
|
14
11
|
const sourceFileToSnapshotMap = new WeakMap();
|
|
15
12
|
const files = (0, language_core_1.createFileProvider)(getLanguagePlugins(ts, options), ts.sys.useCaseSensitiveFileNames, fileName => {
|
|
16
13
|
let snapshot;
|
|
@@ -43,6 +40,7 @@ function proxyCreateProgram(ts, original, extensions, getLanguagePlugins) {
|
|
|
43
40
|
const originalSourceFiles = new Map();
|
|
44
41
|
const parsedSourceFiles = new WeakMap();
|
|
45
42
|
const arbitraryExtensions = extensions.map(ext => `.d${ext}.ts`);
|
|
43
|
+
const originalHost = options.host;
|
|
46
44
|
const moduleResolutionHost = {
|
|
47
45
|
...originalHost,
|
|
48
46
|
fileExists(fileName) {
|
|
@@ -54,6 +52,8 @@ function proxyCreateProgram(ts, original, extensions, getLanguagePlugins) {
|
|
|
54
52
|
return originalHost.fileExists(fileName);
|
|
55
53
|
},
|
|
56
54
|
};
|
|
55
|
+
options.host = { ...originalHost };
|
|
56
|
+
options.options.allowArbitraryExtensions = true;
|
|
57
57
|
options.host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
58
58
|
const originalSourceFile = originalHost.getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
59
59
|
originalSourceFiles.set(fileName, originalSourceFile);
|
package/lib/starters/runTsc.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.getLanguagePlugins = getLanguagePlugins;
|
|
|
7
7
|
function runTsc(tscPath, extensions, _getLanguagePlugins) {
|
|
8
8
|
exports.getLanguagePlugins = _getLanguagePlugins;
|
|
9
9
|
const proxyApiPath = require.resolve('../node/proxyCreateProgram');
|
|
10
|
-
const currentFilePath = require.resolve('./runTsc');
|
|
11
10
|
const readFileSync = fs.readFileSync;
|
|
12
11
|
fs.readFileSync = (...args) => {
|
|
13
12
|
if (args[0] === tscPath) {
|
|
@@ -22,14 +21,20 @@ function runTsc(tscPath, extensions, _getLanguagePlugins) {
|
|
|
22
21
|
+ `new Proxy({}, { get(_target, p, _receiver) {return eval(p); } } ), `
|
|
23
22
|
+ `_createProgram, `
|
|
24
23
|
+ `[${extsText}], `
|
|
25
|
-
+ `require(${JSON.stringify(
|
|
24
|
+
+ `require(${JSON.stringify(__filename)}).getLanguagePlugins`
|
|
26
25
|
+ `);\n`
|
|
27
26
|
+ s.replace('createProgram', '_createProgram'));
|
|
28
27
|
return tsc;
|
|
29
28
|
}
|
|
30
29
|
return readFileSync(...args);
|
|
31
30
|
};
|
|
32
|
-
|
|
31
|
+
try {
|
|
32
|
+
require(tscPath);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
fs.readFileSync = readFileSync;
|
|
36
|
+
delete require.cache[tscPath];
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
exports.runTsc = runTsc;
|
|
35
40
|
function replace(text, ...[search, replace]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/typescript",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"directory": "packages/typescript"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.0.0-alpha.
|
|
15
|
+
"@volar/language-core": "2.0.0-alpha.5",
|
|
16
16
|
"path-browserify": "^1.0.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "latest",
|
|
20
20
|
"@types/path-browserify": "latest",
|
|
21
|
-
"@volar/language-service": "2.0.0-alpha.
|
|
21
|
+
"@volar/language-service": "2.0.0-alpha.5"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "80f4f8791c304fbcf4a0a8425eae8ea0b5ab739c"
|
|
24
24
|
}
|