Skip to content

Commit f8d2857

Browse files
committed
tsserverlibrary
1 parent b6d5279 commit f8d2857

4 files changed

Lines changed: 48 additions & 7 deletions

File tree

Jakefile.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ const Paths = {
4747
builtLocalRun: "built/local/run.js",
4848
locLcg: "built/local/enu/diagnosticMessages.generated.json.lcg",
4949
typesMapOutput: "built/local/typesMap.json",
50+
5051
servicesFile: "built/local/typescriptServices.js",
5152
servicesDefinitionFile: "built/local/typescriptServices.d.ts",
5253

54+
tsserverGlobalLibraryFile: "built/local/tsserverGlobalLibrary.js",
55+
tsserverGlobalLibraryDefinitionFile: "built/local/tsserverGlobalLibrary.d.ts",
5356
tsserverLibraryFile: "built/local/tsserverlibrary.js",
5457
tsserverLibraryDefinitionFile: "built/local/tsserverlibrary.d.ts",
5558

@@ -161,7 +164,7 @@ task(TaskNames.lkg, [
161164
const sizeBefore = getDirSize(Paths.lkg);
162165
const localizationTargets = locales.map(f => path.join(Paths.builtLocal, f)).concat(path.dirname(Paths.locLcg));
163166

164-
const copyrightContent = fs.readFileSync(Paths.copyright, { encoding: 'utf-8' });
167+
const copyrightContent = readFileSync(Paths.copyright);
165168

166169
const expectedFiles = [...libraryTargets, ...ExpectedLKGFiles, ...localizationTargets];
167170
const missingFiles = expectedFiles.filter(f => !fs.existsSync(f));
@@ -172,7 +175,7 @@ task(TaskNames.lkg, [
172175
// Copy all the targets into the LKG directory
173176
jake.mkdirP(Paths.lkg);
174177
expectedFiles.forEach(f => {
175-
let content = fs.readFileSync(f, { encoding: 'utf-8' });
178+
let content = readFileSync(f);
176179

177180
// If this is a .d.ts file, run remove-internal on it
178181
if (f.endsWith(".d.ts")) {
@@ -282,7 +285,7 @@ file(Paths.diagnosticInformationMap, [Paths.diagnosticMessagesJson], function (c
282285
}, { async: true });
283286

284287
file(Paths.typesMapOutput, /** @type {*} */(function () {
285-
var content = fs.readFileSync(path.join(Paths.srcServer, 'typesMap.json'));
288+
var content = readFileSync(path.join(Paths.srcServer, 'typesMap.json'));
286289
// Validate that it's valid JSON
287290
try {
288291
JSON.parse(content.toString());
@@ -293,18 +296,21 @@ file(Paths.typesMapOutput, /** @type {*} */(function () {
293296
}));
294297

295298
file(Paths.tsserverLibraryFile, [TaskNames.coreBuild, Paths.copyright, ...libraryTargets], function() {
296-
// fs.writeFileSync(Paths.tsserverLibraryFile, fs.readFileSync(path.join(Paths.builtLocal, "server.js"), { encoding: 'utf-8'}));
297-
fs.writeFileSync(Paths.tsserverLibraryFile, "wat");
299+
const originalContent = readFileSync(Paths.tsserverGlobalLibraryFile);
300+
const newContent =
301+
readFileSync(Paths.copyright) +
302+
originalContent;
303+
writeFileSync(Paths.tsserverLibraryFile, newContent);
298304
});
299305

300306
file(Paths.tsserverLibraryDefinitionFile, [TaskNames.coreBuild, Paths.copyright, ...libraryTargets], function () {
301-
const content = fs.readFileSync(Paths.servicesFile, { encoding: 'utf-8' });
307+
const content = readFileSync(Paths.tsserverGlobalLibraryDefinitionFile);
302308
const newContent =
303309
removeConstModifierFromEnumDeclarations(content) +
304310
`\nexport = ts` +
305311
`\nexport as namespace ts;`;
306312

307-
fs.writeFileSync(Paths.tsserverLibraryDefinitionFile, newContent, { encoding: 'utf-8' });
313+
writeFileSync(Paths.tsserverLibraryDefinitionFile, newContent);
308314
});
309315

310316
function getLibraryTargets() {
@@ -657,3 +663,18 @@ function getDiffTool() {
657663
function removeConstModifierFromEnumDeclarations(text) {
658664
return text.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4');
659665
}
666+
667+
/**
668+
* @param {string} path
669+
*/
670+
function readFileSync(path) {
671+
return fs.readFileSync(path, { encoding: "utf-8" });
672+
}
673+
674+
/**
675+
* @param {string} path
676+
* @param {string} contents
677+
*/
678+
function writeFileSync(path, contents) {
679+
fs.writeFileSync(path, contents, { encoding: "utf-8" });
680+
}

src/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"references": [
55
{ "path": "./tsc" },
66
{ "path": "./tsserver" },
7+
{ "path": "./tsserverLibrary" },
78
{ "path": "./typingsInstaller" },
89
{ "path": "./watchGuard" },
910
{ "path": "./cancellationToken" },

src/tsserverLibrary/empty.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Workaround file, please delete once tsbuild understands it's not safe to skip this container

src/tsserverLibrary/tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "../tsconfig-base",
3+
4+
"compilerOptions": {
5+
"outFile": "../../built/local/tsserverGlobalLibrary.js",
6+
"types": [
7+
"node"
8+
]
9+
},
10+
"files": ["empty.ts"],
11+
"references": [
12+
{ "path": "../core", "prepend": true },
13+
{ "path": "../parser", "prepend": true },
14+
{ "path": "../compiler", "prepend": true },
15+
{ "path": "../services", "prepend": true },
16+
{ "path": "../server", "prepend": true }
17+
]
18+
}

0 commit comments

Comments
 (0)