Move tsserverlibrary.js to typescript.js, make tsserverlibrary.js a shim (#55273)

This commit is contained in:
Jake Bailey 2023-08-14 12:45:27 -07:00 коммит произвёл GitHub
Родитель fd390e78fe
Коммит 3c6c557039
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 4105 добавлений и 11401 удалений

Просмотреть файл

@ -404,27 +404,50 @@ export const watchMin = task({
const { main: lssl, build: buildLssl, watch: watchLssl } = entrypointBuildTask({
// This is technically not enough to make tsserverlibrary loadable in the
// browser, but it's unlikely that anyone has actually been doing that.
const lsslJs = `
if (typeof module !== "undefined" && module.exports) {
module.exports = require("./typescript.js");
}
else {
throw new Error("tsserverlibrary requires CommonJS; use typescript.js instead");
}
`;
const lsslDts = `
import ts = require("./typescript.js");
export = ts;
`;
const lsslDtsInternal = `
import ts = require("./typescript.internal.js");
export = ts;
`;
/**
* @param {string} contents
*/
async function fileContentsWithCopyright(contents) {
return await copyright() + contents.trim().replace(/\r\n/g, "\n") + "\n";
}
const lssl = task({
name: "lssl",
description: "Builds language service server library",
buildDeps: [generateDiagnostics],
project: "src/tsserverlibrary",
srcEntrypoint: "./src/tsserverlibrary/tsserverlibrary.ts",
builtEntrypoint: "./built/local/tsserverlibrary/tsserverlibrary.js",
output: "./built/local/tsserverlibrary.js",
mainDeps: [generateLibs],
bundlerOptions: { exportIsTsObject: true },
dependencies: [services],
run: async () => {
await fs.promises.writeFile("./built/local/tsserverlibrary.js", await fileContentsWithCopyright(lsslJs));
}
});
export { lssl, watchLssl };
export const dtsLssl = task({
name: "dts-lssl",
description: "Bundles tsserverlibrary.d.ts",
dependencies: [buildLssl],
dependencies: [dtsServices],
run: async () => {
if (needsUpdate("./built/local/tsserverlibrary/tsconfig.tsbuildinfo", ["./built/local/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.internal.d.ts"])) {
await runDtsBundler("./built/local/tsserverlibrary/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.d.ts");
}
await fs.promises.writeFile("./built/local/tsserverlibrary.d.ts", await fileContentsWithCopyright(lsslDts));
await fs.promises.writeFile("./built/local/tsserverlibrary.internal.d.ts", await fileContentsWithCopyright(lsslDtsInternal));
}
});
@ -563,7 +586,7 @@ export const watchLocal = task({
name: "watch-local",
description: "Watches the full compiler and services",
hiddenFromTaskList: true,
dependencies: [localize, watchTsc, watchTsserver, watchServices, watchLssl, watchOtherOutputs, dts, watchSrc],
dependencies: [localize, watchTsc, watchTsserver, watchServices, lssl, watchOtherOutputs, dts, watchSrc],
});
const runtestsDeps = [tests, generateLibs].concat(cmdLineOptions.typecheck ? [dts] : []);

Просмотреть файл

@ -1,4 +1,3 @@
import * as compiler from "../_namespaces/compiler";
import * as documents from "../_namespaces/documents";
import * as fakes from "../_namespaces/fakes";
import * as Harness from "../_namespaces/Harness";
@ -19,21 +18,6 @@ describe("unittests:: Public APIs", () => {
it("should be acknowledged when they change", () => {
Harness.Baseline.runBaseline(api, fileContent, { PrintDiff: true });
});
it("should compile", () => {
const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ false);
fs.linkSync(`${vfs.builtFolder}/${fileName}`, `${vfs.srcFolder}/${fileName}`);
const sys = new fakes.System(fs);
const options: ts.CompilerOptions = {
...ts.getDefaultCompilerOptions(),
strict: true,
exactOptionalPropertyTypes: true,
lib: ["lib.es2018.d.ts"],
};
const host = new fakes.CompilerHost(sys, options);
const result = compiler.compileFiles(host, [`${vfs.srcFolder}/${fileName}`], options);
assert(!result.diagnostics || !result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(result.diagnostics, /*pretty*/ true));
});
}
describe("for the language service and compiler", () => {

Просмотреть файл

@ -13,7 +13,6 @@
{ "path": "./testRunner" },
{ "path": "./tsc" },
{ "path": "./tsserver" },
{ "path": "./tsserverlibrary" },
{ "path": "./typescript" },
{ "path": "./typingsInstaller" },
{ "path": "./typingsInstallerCore" },

Просмотреть файл

@ -1,8 +0,0 @@
/* Generated file to emulate the ts namespace. */
export * from "../../compiler/_namespaces/ts";
export * from "../../jsTyping/_namespaces/ts";
export * from "../../services/_namespaces/ts";
export * from "../../server/_namespaces/ts";
import * as server from "./ts.server";
export { server };

Просмотреть файл

@ -1,12 +0,0 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
},
"references": [
{ "path": "../compiler" },
{ "path": "../jsTyping" },
{ "path": "../services" },
{ "path": "../server" }
],
"include": ["**/*"]
}

Просмотреть файл

@ -1,3 +0,0 @@
import * as ts from "./_namespaces/ts";
export = ts;

Просмотреть файл

@ -3,4 +3,6 @@
export * from "../../compiler/_namespaces/ts";
export * from "../../jsTyping/_namespaces/ts";
export * from "../../services/_namespaces/ts";
export * from "../../deprecatedCompat/_namespaces/ts";
export * from "../../server/_namespaces/ts";
import * as server from "./ts.server";
export { server };

Просмотреть файл

@ -6,7 +6,7 @@
{ "path": "../compiler" },
{ "path": "../jsTyping" },
{ "path": "../services" },
{ "path": "../deprecatedCompat" }
{ "path": "../server" }
],
"include": ["**/*"]
}

Просмотреть файл

@ -8,8 +8,8 @@ import tsInternal = require("typescript-internal");
>tsInternal : typeof tsInternal
import tsserverlibrary = require("tsserverlibrary");
>tsserverlibrary : typeof tsserverlibrary
>tsserverlibrary : typeof ts
import tsserverlibraryInternal = require("tsserverlibrary-internal");
>tsserverlibraryInternal : typeof tsserverlibraryInternal
>tsserverlibraryInternal : typeof tsInternal

Разница между файлами не показана из-за своего большого размера Загрузить разницу

4144
tests/baselines/reference/api/typescript.d.ts поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу