mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 03:20:56 -06:00
tsserverlibrary
This commit is contained in:
parent
b6d5279333
commit
f8d2857e25
35
Jakefile.js
35
Jakefile.js
@ -47,9 +47,12 @@ const Paths = {
|
||||
builtLocalRun: "built/local/run.js",
|
||||
locLcg: "built/local/enu/diagnosticMessages.generated.json.lcg",
|
||||
typesMapOutput: "built/local/typesMap.json",
|
||||
|
||||
servicesFile: "built/local/typescriptServices.js",
|
||||
servicesDefinitionFile: "built/local/typescriptServices.d.ts",
|
||||
|
||||
tsserverGlobalLibraryFile: "built/local/tsserverGlobalLibrary.js",
|
||||
tsserverGlobalLibraryDefinitionFile: "built/local/tsserverGlobalLibrary.d.ts",
|
||||
tsserverLibraryFile: "built/local/tsserverlibrary.js",
|
||||
tsserverLibraryDefinitionFile: "built/local/tsserverlibrary.d.ts",
|
||||
|
||||
@ -161,7 +164,7 @@ task(TaskNames.lkg, [
|
||||
const sizeBefore = getDirSize(Paths.lkg);
|
||||
const localizationTargets = locales.map(f => path.join(Paths.builtLocal, f)).concat(path.dirname(Paths.locLcg));
|
||||
|
||||
const copyrightContent = fs.readFileSync(Paths.copyright, { encoding: 'utf-8' });
|
||||
const copyrightContent = readFileSync(Paths.copyright);
|
||||
|
||||
const expectedFiles = [...libraryTargets, ...ExpectedLKGFiles, ...localizationTargets];
|
||||
const missingFiles = expectedFiles.filter(f => !fs.existsSync(f));
|
||||
@ -172,7 +175,7 @@ task(TaskNames.lkg, [
|
||||
// Copy all the targets into the LKG directory
|
||||
jake.mkdirP(Paths.lkg);
|
||||
expectedFiles.forEach(f => {
|
||||
let content = fs.readFileSync(f, { encoding: 'utf-8' });
|
||||
let content = readFileSync(f);
|
||||
|
||||
// If this is a .d.ts file, run remove-internal on it
|
||||
if (f.endsWith(".d.ts")) {
|
||||
@ -282,7 +285,7 @@ file(Paths.diagnosticInformationMap, [Paths.diagnosticMessagesJson], function (c
|
||||
}, { async: true });
|
||||
|
||||
file(Paths.typesMapOutput, /** @type {*} */(function () {
|
||||
var content = fs.readFileSync(path.join(Paths.srcServer, 'typesMap.json'));
|
||||
var content = readFileSync(path.join(Paths.srcServer, 'typesMap.json'));
|
||||
// Validate that it's valid JSON
|
||||
try {
|
||||
JSON.parse(content.toString());
|
||||
@ -293,18 +296,21 @@ file(Paths.typesMapOutput, /** @type {*} */(function () {
|
||||
}));
|
||||
|
||||
file(Paths.tsserverLibraryFile, [TaskNames.coreBuild, Paths.copyright, ...libraryTargets], function() {
|
||||
// fs.writeFileSync(Paths.tsserverLibraryFile, fs.readFileSync(path.join(Paths.builtLocal, "server.js"), { encoding: 'utf-8'}));
|
||||
fs.writeFileSync(Paths.tsserverLibraryFile, "wat");
|
||||
const originalContent = readFileSync(Paths.tsserverGlobalLibraryFile);
|
||||
const newContent =
|
||||
readFileSync(Paths.copyright) +
|
||||
originalContent;
|
||||
writeFileSync(Paths.tsserverLibraryFile, newContent);
|
||||
});
|
||||
|
||||
file(Paths.tsserverLibraryDefinitionFile, [TaskNames.coreBuild, Paths.copyright, ...libraryTargets], function () {
|
||||
const content = fs.readFileSync(Paths.servicesFile, { encoding: 'utf-8' });
|
||||
const content = readFileSync(Paths.tsserverGlobalLibraryDefinitionFile);
|
||||
const newContent =
|
||||
removeConstModifierFromEnumDeclarations(content) +
|
||||
`\nexport = ts` +
|
||||
`\nexport as namespace ts;`;
|
||||
|
||||
fs.writeFileSync(Paths.tsserverLibraryDefinitionFile, newContent, { encoding: 'utf-8' });
|
||||
writeFileSync(Paths.tsserverLibraryDefinitionFile, newContent);
|
||||
});
|
||||
|
||||
function getLibraryTargets() {
|
||||
@ -657,3 +663,18 @@ function getDiffTool() {
|
||||
function removeConstModifierFromEnumDeclarations(text) {
|
||||
return text.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
*/
|
||||
function readFileSync(path) {
|
||||
return fs.readFileSync(path, { encoding: "utf-8" });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @param {string} contents
|
||||
*/
|
||||
function writeFileSync(path, contents) {
|
||||
fs.writeFileSync(path, contents, { encoding: "utf-8" });
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
"references": [
|
||||
{ "path": "./tsc" },
|
||||
{ "path": "./tsserver" },
|
||||
{ "path": "./tsserverLibrary" },
|
||||
{ "path": "./typingsInstaller" },
|
||||
{ "path": "./watchGuard" },
|
||||
{ "path": "./cancellationToken" },
|
||||
|
||||
1
src/tsserverLibrary/empty.ts
Normal file
1
src/tsserverLibrary/empty.ts
Normal file
@ -0,0 +1 @@
|
||||
// Workaround file, please delete once tsbuild understands it's not safe to skip this container
|
||||
18
src/tsserverLibrary/tsconfig.json
Normal file
18
src/tsserverLibrary/tsconfig.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
|
||||
"compilerOptions": {
|
||||
"outFile": "../../built/local/tsserverGlobalLibrary.js",
|
||||
"types": [
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"files": ["empty.ts"],
|
||||
"references": [
|
||||
{ "path": "../core", "prepend": true },
|
||||
{ "path": "../parser", "prepend": true },
|
||||
{ "path": "../compiler", "prepend": true },
|
||||
{ "path": "../services", "prepend": true },
|
||||
{ "path": "../server", "prepend": true }
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user