Skip to content

Commit 1c4e72a

Browse files
committed
share TypeScipt node_module amongst extensions
1 parent 38c5406 commit 1c4e72a

13 files changed

Lines changed: 120 additions & 64320 deletions

File tree

build/npm/postinstall.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
const cp = require('child_process');
77
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
88

9+
function npmInstall(location) {
10+
const result = cp.spawnSync(npm, ['install'], {
11+
cwd: location ,
12+
stdio: 'inherit'
13+
});
14+
15+
if (result.error || result.status !== 0) {
16+
process.exit(1);
17+
}
18+
}
19+
20+
npmInstall('extensions'); // node modules shared by all extensions
21+
922
const extensions = [
1023
'vscode-api-tests',
1124
'vscode-colorize-tests',
@@ -20,13 +33,4 @@ const extensions = [
2033
'html'
2134
];
2235

23-
extensions.forEach(extension => {
24-
const result = cp.spawnSync(npm, ['install'], {
25-
cwd: `extensions/${extension}`,
26-
stdio: 'inherit'
27-
});
28-
29-
if (result.error || result.status !== 0) {
30-
process.exit(1);
31-
}
32-
});
36+
extensions.forEach(extension => npmInstall(`extensions/${extension}`));

extensions/extension-editing/npm-shrinkwrap.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/extension-editing/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
],
1414
"main": "./out/extension",
1515
"scripts": {
16-
"postinstall": "node ./postinstall",
1716
"compile": "gulp compile-extension:extension-editing",
1817
"watch": "gulp watch-extension:extension-editing"
1918
},
20-
"dependencies": {
21-
"typescript": "^1.8.10"
22-
},
2319
"contributes": {
2420
"jsonValidation": [
2521
{

extensions/extension-editing/postinstall.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

extensions/html/server/src/modes/javascriptMode.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@ import { CompletionItem, Location, SignatureHelp, SignatureInformation, Paramete
99
import { LanguageMode } from './languageModes';
1010
import { getWordAtText } from '../utils/words';
1111

12-
import ts = require('./typescript/typescriptServices');
13-
import { contents as libdts } from './typescript/lib-ts';
12+
import * as ts from 'typescript';
1413

15-
const DEFAULT_LIB = {
16-
NAME: 'defaultLib:lib.d.ts',
17-
CONTENTS: libdts
18-
};
19-
const FILE_NAME = 'typescript://singlefile/1'; // the same 'file' is used for all contents
14+
const FILE_NAME = 'vscode://javascript/1'; // the same 'file' is used for all contents
2015

2116
const JS_WORD_REGEX = /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;
2217

@@ -33,15 +28,15 @@ export function getJavascriptMode(jsDocuments: LanguageModelCache<TextDocument>)
3328
return '1'; // default lib is static
3429
},
3530
getScriptSnapshot: (fileName: string) => {
36-
let text = fileName === FILE_NAME ? currentTextDocument.getText() : DEFAULT_LIB.CONTENTS;
31+
let text = fileName === FILE_NAME ? currentTextDocument.getText() : ts.sys.readFile(fileName);
3732
return {
3833
getText: (start, end) => text.substring(start, end),
3934
getLength: () => text.length,
4035
getChangeRange: () => void 0
4136
};
4237
},
43-
getCurrentDirectory: () => '',
44-
getDefaultLibFileName: options => DEFAULT_LIB.NAME
38+
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
39+
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options)
4540
};
4641
let jsLanguageService = ts.createLanguageService(host);
4742

extensions/html/server/src/modes/typescript/lib-ts.d.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

extensions/html/server/src/modes/typescript/lib-ts.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)