提交 434def67 编写于 作者: M Matt Bierner 提交者: GitHub

Use common TS install for both the TS Extension and Html Extension (#21578)

* Use common TS install for both the TS Extension and Html Extension

**Bug**
At least two version of Typescript are shipped in our extensions: one in the typescript extension and one for the html extension. This adds about 5MB to package install size and also results in inconsistent behavior

**Fix**
Change the TypeScript extension to also use the common version of TypeScript. Bump this version up to 2.2.1

* Don't hardcode paths for typescript
上级 6b74e23c
......@@ -3,9 +3,9 @@
"version": "0.0.1",
"dependencies": {
"typescript": {
"version": "2.1.6",
"from": "typescript@2.1.6",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.1.6.tgz"
"version": "2.2.1",
"from": "typescript@typescript@2.2.1",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.2.1.tgz"
}
}
}
......@@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Dependencies shared by all extensions",
"dependencies": {
"typescript": "2.1.6"
"typescript": "2.2.1"
},
"scripts": {
"postinstall": "node ./postinstall"
......
......@@ -7,28 +7,20 @@
const fs = require('fs');
const path = require('path');
const toDelete = new Set(['tsc.js', 'tsserverlibrary.js', 'typescript.js', 'typescriptServices.js']);
function removeFile(filePath) {
try {
fs.unlinkSync(filePath);
console.log(`removed '${filePath}'`);
} catch (e) {
console.warn(e);
const root = path.join(__dirname, 'node_modules', 'typescript', 'lib');
for (let name of fs.readdirSync(root)) {
if (name === 'lib.d.ts' || name.match(/^lib\..*\.d\.ts$/) || name === 'protocol.d.ts') {
continue;
}
}
// delete unused typescript stuff in lib folder
const libPath = path.dirname(require.resolve('typescript'));
for (let name of fs.readdirSync(libPath)) {
if (name !== 'typescript.d.ts' && name !== 'typescript.js' && name !== 'lib.es6.d.ts') {
removeFile(path.join(libPath, name));
if (toDelete.has(name) || name.match(/\.d\.ts$/)) {
try {
fs.unlinkSync(path.join(root, name));
console.log(`removed '${path.join(root, name)}'`);
} catch (e) {
console.warn(e);
}
}
}
// delete unused typescript stuff in bin folder
const binPath = path.join(path.dirname(libPath), 'bin');
for (let name of fs.readdirSync(binPath)) {
removeFile(path.join(binPath, name));
}
removeFile(path.join(path.dirname(libPath), 'Gulpfile.ts'));
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
const fs = require('fs');
const path = require('path');
const toDelete = new Set(['tsc.js', 'tsserverlibrary.js', 'typescript.js', 'typescriptServices.js']);
const root = path.join(__dirname, '..', 'node_modules', 'typescript', 'lib');
for (let name of fs.readdirSync(root)) {
if (name === 'lib.d.ts' || name.match(/^lib\..*\.d\.ts$/) || name === 'protocol.d.ts') {
continue;
}
if (toDelete.has(name) || name.match(/\.d\.ts$/)) {
try {
fs.unlinkSync(path.join(root, name));
console.log(`removed '${path.join(root, name)}'`);
} catch (e) {
console.warn(e);
}
}
}
\ No newline at end of file
......@@ -12,11 +12,6 @@
"from": "semver@4.3.6",
"resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz"
},
"typescript": {
"version": "2.2.1",
"from": "typescript@typescript@2.2.1",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.2.1.tgz"
},
"vscode-extension-telemetry": {
"version": "0.0.6",
"from": "vscode-extension-telemetry@>=0.0.6 <0.0.7",
......
......@@ -13,15 +13,13 @@
"dependencies": {
"semver": "4.3.6",
"vscode-extension-telemetry": "^0.0.6",
"vscode-nls": "^2.0.1",
"typescript": "typescript@2.2.1"
"vscode-nls": "^2.0.1"
},
"devDependencies": {
"@types/node": "^7.0.4",
"@types/semver": "^5.3.30"
},
"scripts": {
"postinstall": "node ./bin/postinstall",
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:typescript ./tsconfig.json",
"update-grammars": "node ./build/update-grammars.js"
},
......
import * as Proto from '../node_modules/typescript/lib/protocol';
import * as Proto from 'typescript/lib/protocol';
export = Proto;
\ No newline at end of file
......@@ -328,7 +328,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
private get bundledTypeScriptPath(): string {
return path.join(__dirname, '..', 'node_modules', 'typescript', 'lib', 'tsserver.js');
return require.resolve('typescript/lib/tsserver.js');
}
private get localTypeScriptPath(): string | null {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册