From 7bf267c197fc6a5cbafa0e72992b1cc7629ff989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 11 Dec 2023 16:59:09 +0100 Subject: perf(lsp): simplify some of the startup code (#21538) Remove some dead code in "99_main_compiler.js". Eagerly start the LSP TSC host, it was adding some not needed complexity around the TSC thread code. --- cli/tsc/99_main_compiler.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'cli/tsc/99_main_compiler.js') diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index 8f76425c1..d795e542b 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -519,6 +519,7 @@ delete Object.prototype.__proto__; if (logDebug) { debug(`host.fileExists("${specifier}")`); } + // TODO(bartlomieju): is this assumption still valid? // this is used by typescript to find the libs path // so we can completely ignore it return false; @@ -963,6 +964,9 @@ delete Object.prototype.__proto__; * @param {number} id * @param {any} data */ + // TODO(bartlomieju): this feels needlessly generic, both type chcking + // and language server use it with inefficient serialization. Id is not used + // anyway... function respond(id, data = null) { ops.op_respond({ id, data }); } @@ -1046,6 +1050,7 @@ delete Object.prototype.__proto__; } } + let hasStarted = false; /** @param {{ debug: boolean; }} init */ function serverInit({ debug: debugFlag }) { if (hasStarted) { @@ -1063,19 +1068,6 @@ delete Object.prototype.__proto__; debug("serverRestart()"); } - let hasStarted = false; - - /** Startup the runtime environment, setting various flags. - * @param {{ debugFlag?: boolean; legacyFlag?: boolean; }} msg - */ - function startup({ debugFlag = false }) { - if (hasStarted) { - throw new Error("The compiler runtime already started."); - } - hasStarted = true; - setLogDebug(!!debugFlag, "TS"); - } - // A build time only op that provides some setup information that is used to // ensure the snapshot is setup properly. /** @type {{ buildSpecifier: string; libs: string[]; nodeBuiltInModuleNames: string[] }} */ @@ -1161,7 +1153,6 @@ delete Object.prototype.__proto__; // checking TypeScript. /** @type {any} */ const global = globalThis; - global.startup = startup; global.exec = exec; global.getAssets = getAssets; -- cgit v1.2.3