Skip to content

Commit 384ab90

Browse files
committed
Move compiler-debug into Debug namespace, which allows the compiler to be tree shaken
This debug code was added quite a while ago, constructed such that we wouldn't have to ship this code to our users. However, this is the sole place in the compiler project where the ts namespace "escapes" the bundle. By moving this debug code into the compiler itself, we no longer have any references to the ts namespace itself for our bundles that don't export anything (tsc, typingsInstaller). This lets bundlers tree shake the compiler, reducing the size of our output by _5.7 MB_ (a ridiculous improvement for _adding_ code).
1 parent a7d2107 commit 384ab90

File tree

5 files changed

+390
-575
lines changed

5 files changed

+390
-575
lines changed

Diff for: Herebyfile.mjs

+5-15
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,6 @@ function entrypointBuildTask(options) {
320320
return { build, bundle, shim, main };
321321
}
322322

323-
const { main: compilerDebug } = entrypointBuildTask({
324-
name: "compiler-debug",
325-
buildDeps: [generateDiagnostics],
326-
project: "src/debug",
327-
srcEntrypoint: "./src/debug/compilerDebug.ts",
328-
builtEntrypoint: "./built/local/debug/compilerDebug.js",
329-
output: "./built/local/compiler-debug.js",
330-
});
331-
332-
333323
const { main: tsc } = entrypointBuildTask({
334324
name: "tsc",
335325
description: "Builds the command-line compiler",
@@ -338,7 +328,7 @@ const { main: tsc } = entrypointBuildTask({
338328
srcEntrypoint: "./src/tsc/tsc.ts",
339329
builtEntrypoint: "./built/local/tsc/tsc.js",
340330
output: "./built/local/tsc.js",
341-
mainDeps: [generateLibs, compilerDebug],
331+
mainDeps: [generateLibs],
342332
});
343333
export { tsc };
344334

@@ -351,7 +341,7 @@ const { main: services, build: buildServices } = entrypointBuildTask({
351341
srcEntrypoint: "./src/typescript/typescript.ts",
352342
builtEntrypoint: "./built/local/typescript/typescript.js",
353343
output: "./built/local/typescript.js",
354-
mainDeps: [generateLibs, compilerDebug],
344+
mainDeps: [generateLibs],
355345
esbuildOptions: { exportIsTsObject: true },
356346
});
357347
export { services };
@@ -372,7 +362,7 @@ const { main: tsserver } = entrypointBuildTask({
372362
srcEntrypoint: "./src/tsserver/server.ts",
373363
builtEntrypoint: "./built/local/tsserver/server.js",
374364
output: "./built/local/tsserver.js",
375-
mainDeps: [generateLibs, compilerDebug],
365+
mainDeps: [generateLibs],
376366
// Even though this seems like an exectuable, so could be the default CJS,
377367
// this is used in the browser too. Do the same thing that we do for our
378368
// libraries and generate an IIFE with name `ts`, as to not pollute the global
@@ -397,7 +387,7 @@ const { main: lssl, build: buildLssl } = entrypointBuildTask({
397387
srcEntrypoint: "./src/tsserverlibrary/tsserverlibrary.ts",
398388
builtEntrypoint: "./built/local/tsserverlibrary/tsserverlibrary.js",
399389
output: "./built/local/tsserverlibrary.js",
400-
mainDeps: [generateLibs, compilerDebug],
390+
mainDeps: [generateLibs],
401391
esbuildOptions: { exportIsTsObject: true },
402392
});
403393
export { lssl };
@@ -425,7 +415,7 @@ const { main: tests } = entrypointBuildTask({
425415
srcEntrypoint: "./src/testRunner/_namespaces/Harness.ts",
426416
builtEntrypoint: "./built/local/testRunner/runner.js",
427417
output: testRunner,
428-
mainDeps: [generateLibs, compilerDebug],
418+
mainDeps: [generateLibs],
429419
esbuildOptions: {
430420
// Ensure we never drop any dead code, which might be helpful while debugging.
431421
treeShaking: false,

0 commit comments

Comments
 (0)