Skip to content

Commit

Permalink
Use common TS install for both the TS Extension and Html Extension (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mjbvz authored Mar 2, 2017
1 parent 6b74e23 commit 434def6
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 61 deletions.
6 changes: 3 additions & 3 deletions extensions/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
34 changes: 13 additions & 21 deletions extensions/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
26 changes: 0 additions & 26 deletions extensions/typescript/bin/postinstall.js

This file was deleted.

5 changes: 0 additions & 5 deletions extensions/typescript/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions extensions/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion extensions/typescript/src/protocol.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import * as Proto from '../node_modules/typescript/lib/protocol';
import * as Proto from 'typescript/lib/protocol';
export = Proto;
2 changes: 1 addition & 1 deletion extensions/typescript/src/typescriptServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 434def6

Please sign in to comment.