Skip to content

Commit 67d85a4

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 393d0de commit 67d85a4

File tree

5 files changed

+390
-574
lines changed

5 files changed

+390
-574
lines changed

Diff for: Herebyfile.mjs

+5-14
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,6 @@ function entrypointBuildTask(options) {
360360
return { build, bundle, shim, main, watch };
361361
}
362362

363-
const { main: compilerDebug } = entrypointBuildTask({
364-
name: "compiler-debug",
365-
buildDeps: [generateDiagnostics],
366-
project: "src/debug",
367-
srcEntrypoint: "./src/debug/compilerDebug.ts",
368-
builtEntrypoint: "./built/local/debug/compilerDebug.js",
369-
output: "./built/local/compiler-debug.js",
370-
});
371-
372363

373364
const { main: tsc, watch: watchTsc } = entrypointBuildTask({
374365
name: "tsc",
@@ -378,7 +369,7 @@ const { main: tsc, watch: watchTsc } = entrypointBuildTask({
378369
srcEntrypoint: "./src/tsc/tsc.ts",
379370
builtEntrypoint: "./built/local/tsc/tsc.js",
380371
output: "./built/local/tsc.js",
381-
mainDeps: [generateLibs, compilerDebug],
372+
mainDeps: [generateLibs],
382373
});
383374
export { tsc, watchTsc };
384375

@@ -391,7 +382,7 @@ const { main: services, build: buildServices, watch: watchServices } = entrypoin
391382
srcEntrypoint: "./src/typescript/typescript.ts",
392383
builtEntrypoint: "./built/local/typescript/typescript.js",
393384
output: "./built/local/typescript.js",
394-
mainDeps: [generateLibs, compilerDebug],
385+
mainDeps: [generateLibs],
395386
bundlerOptions: { exportIsTsObject: true },
396387
});
397388
export { services, watchServices };
@@ -412,7 +403,7 @@ const { main: tsserver, watch: watchTsserver } = entrypointBuildTask({
412403
srcEntrypoint: "./src/tsserver/server.ts",
413404
builtEntrypoint: "./built/local/tsserver/server.js",
414405
output: "./built/local/tsserver.js",
415-
mainDeps: [generateLibs, compilerDebug],
406+
mainDeps: [generateLibs],
416407
// Even though this seems like an exectuable, so could be the default CJS,
417408
// this is used in the browser too. Do the same thing that we do for our
418409
// libraries and generate an IIFE with name `ts`, as to not pollute the global
@@ -445,7 +436,7 @@ const { main: lssl, build: buildLssl, watch: watchLssl } = entrypointBuildTask({
445436
srcEntrypoint: "./src/tsserverlibrary/tsserverlibrary.ts",
446437
builtEntrypoint: "./built/local/tsserverlibrary/tsserverlibrary.js",
447438
output: "./built/local/tsserverlibrary.js",
448-
mainDeps: [generateLibs, compilerDebug],
439+
mainDeps: [generateLibs],
449440
bundlerOptions: { exportIsTsObject: true },
450441
});
451442
export { lssl, watchLssl };
@@ -473,7 +464,7 @@ const { main: tests, watch: watchTests } = entrypointBuildTask({
473464
srcEntrypoint: "./src/testRunner/_namespaces/Harness.ts",
474465
builtEntrypoint: "./built/local/testRunner/runner.js",
475466
output: testRunner,
476-
mainDeps: [generateLibs, compilerDebug],
467+
mainDeps: [generateLibs],
477468
bundlerOptions: {
478469
// Ensure we never drop any dead code, which might be helpful while debugging.
479470
treeShaking: false,

0 commit comments

Comments
 (0)