Skip to content

Commit 654a6e3

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 3fa05c2 commit 654a6e3

File tree

5 files changed

+391
-574
lines changed

5 files changed

+391
-574
lines changed

Diff for: Herebyfile.mjs

+5-14
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,6 @@ function entrypointBuildTask(options) {
364364
return { build, bundle, shim, main, watch };
365365
}
366366

367-
const { main: compilerDebug } = entrypointBuildTask({
368-
name: "compiler-debug",
369-
buildDeps: [generateDiagnostics],
370-
project: "src/debug",
371-
srcEntrypoint: "./src/debug/compilerDebug.ts",
372-
builtEntrypoint: "./built/local/debug/compilerDebug.js",
373-
output: "./built/local/compiler-debug.js",
374-
});
375-
376367

377368
const { main: tsc, watch: watchTsc } = entrypointBuildTask({
378369
name: "tsc",
@@ -382,7 +373,7 @@ const { main: tsc, watch: watchTsc } = entrypointBuildTask({
382373
srcEntrypoint: "./src/tsc/tsc.ts",
383374
builtEntrypoint: "./built/local/tsc/tsc.js",
384375
output: "./built/local/tsc.js",
385-
mainDeps: [generateLibs, compilerDebug],
376+
mainDeps: [generateLibs],
386377
});
387378
export { tsc, watchTsc };
388379

@@ -395,7 +386,7 @@ const { main: services, build: buildServices, watch: watchServices } = entrypoin
395386
srcEntrypoint: "./src/typescript/typescript.ts",
396387
builtEntrypoint: "./built/local/typescript/typescript.js",
397388
output: "./built/local/typescript.js",
398-
mainDeps: [generateLibs, compilerDebug],
389+
mainDeps: [generateLibs],
399390
bundlerOptions: { exportIsTsObject: true },
400391
});
401392
export { services, watchServices };
@@ -420,7 +411,7 @@ const { main: tsserver, watch: watchTsserver } = entrypointBuildTask({
420411
srcEntrypoint: "./src/tsserver/server.ts",
421412
builtEntrypoint: "./built/local/tsserver/server.js",
422413
output: "./built/local/tsserver.js",
423-
mainDeps: [generateLibs, compilerDebug],
414+
mainDeps: [generateLibs],
424415
// Even though this seems like an exectuable, so could be the default CJS,
425416
// this is used in the browser too. Do the same thing that we do for our
426417
// libraries and generate an IIFE with name `ts`, as to not pollute the global
@@ -453,7 +444,7 @@ const { main: lssl, build: buildLssl, watch: watchLssl } = entrypointBuildTask({
453444
srcEntrypoint: "./src/tsserverlibrary/tsserverlibrary.ts",
454445
builtEntrypoint: "./built/local/tsserverlibrary/tsserverlibrary.js",
455446
output: "./built/local/tsserverlibrary.js",
456-
mainDeps: [generateLibs, compilerDebug],
447+
mainDeps: [generateLibs],
457448
bundlerOptions: { exportIsTsObject: true },
458449
});
459450
export { lssl, watchLssl };
@@ -485,7 +476,7 @@ const { main: tests, watch: watchTests } = entrypointBuildTask({
485476
srcEntrypoint: "./src/testRunner/_namespaces/Harness.ts",
486477
builtEntrypoint: "./built/local/testRunner/runner.js",
487478
output: testRunner,
488-
mainDeps: [generateLibs, compilerDebug],
479+
mainDeps: [generateLibs],
489480
bundlerOptions: {
490481
// Ensure we never drop any dead code, which might be helpful while debugging.
491482
treeShaking: false,

0 commit comments

Comments
 (0)