Skip to content

Move compiler-debug into Debug namespace, which allows the compiler to be tree shaken #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jakebailey
Copy link
Owner

@jakebailey jakebailey commented Oct 3, 2022

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).


Please do not comment on this PR. Depending on how this set of PRs evolves, this PR's contents may change entirely based on the order of commits.

This PR is a part of a stack:

  1. Make a few changes to allow all code to be loaded as one project
  2. Explicitly reference ts namespace in tsserverlibrary
  3. Generated module conversion step - unindent
  4. Generated module conversion step - explicitify
  5. Generated module conversion step - stripNamespaces
  6. Generated module conversion step - inlineImports
  7. Generated module conversion step - .git-ignore-blame-revs
  8. Add gitlens settings suggestion
  9. Make processDiagnosticMessages generate a module
  10. Fix up linting, make lint clean
  11. Undo changes needed to load codebase into ts-morph
  12. Add JSDoc eslint rule
  13. Fix all internal JSDoc comments
  14. Convert require calls to imports
  15. Remove typescriptServices, protocol.d.ts, typescript_standalone.d.ts
  16. Get codebase building pre bundling
  17. Add build via esbuild
  18. Add dts bundling
  19. Consolidate checks that test if the current environment is Node
  20. Add ts to globalThis in run.js for convenience during debugging
  21. Rename Gulpfile to Herebyfile for improved git diff
  22. Change build system to hereby
  23. Update baselines for corrected line endings in lib files
  24. Use jsonc-parser instead of LKG compiler in build
  25. Modernize localize script, use new XML library
  26. Don't use needsUpdate for quick tasks
  27. Remove mkdirp
  28. Export ts namespace from tsserver for hacky-post patching
  29. Directly import namespaces for improved esbuild output
  30. Ensure ts object passed to plugins contains deprecatedCompat declarations
  31. Move compiler-debug into Debug namespace, which allows the compiler to be tree shaken (this PR)
  32. Remove Promise redeclaration
  33. Remove globalThisShim and globalThis modification for TypeScriptServicesFactory
  34. Disable slow CodeQL queries
  35. Remove outFiles from launch.json
  36. Remove dynamicImport and setDynamicImport

@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 79f21b3 to ce2b59b Compare October 10, 2022 17:10
@jakebailey jakebailey changed the title Undo changes needed to load codebase into ts-morph Change build system to hereby Oct 10, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from c71f8ba to b88df81 Compare October 10, 2022 17:10
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from ce2b59b to b124ac1 Compare October 10, 2022 21:05
@jakebailey jakebailey changed the title Change build system to hereby Rename Gulpfile to Herebyfile for improved git diff Oct 10, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch 2 times, most recently from 5c81d1a to 3d4c9f0 Compare October 10, 2022 22:54
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 435ba70 to 49047e7 Compare October 10, 2022 23:14
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 3d4c9f0 to 2d7af0f Compare October 10, 2022 23:14
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 49047e7 to a96025d Compare October 10, 2022 23:31
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 2d7af0f to 41e57d6 Compare October 10, 2022 23:31
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from a96025d to 26681a1 Compare October 11, 2022 23:15
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 41e57d6 to 95bb6e2 Compare October 11, 2022 23:15
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 26681a1 to 535e94d Compare October 11, 2022 23:31
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 95bb6e2 to f782b2c Compare October 11, 2022 23:31
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 535e94d to b0f7ebf Compare October 12, 2022 22:48
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from f782b2c to e5fd341 Compare October 12, 2022 22:48
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from b0f7ebf to 9a8a98e Compare October 14, 2022 19:36
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from e5fd341 to 26ba28d Compare October 14, 2022 19:36
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 9a8a98e to c08a758 Compare October 14, 2022 21:20
@jakebailey jakebailey changed the title Rename Gulpfile to Herebyfile for improved git diff Change build system to hereby Oct 14, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 26ba28d to 9c72255 Compare October 14, 2022 21:20
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from c08a758 to 3e53449 Compare October 14, 2022 22:28
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 9c72255 to 229d522 Compare October 14, 2022 22:28
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 3e53449 to 725b6c7 Compare October 14, 2022 23:34
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 229d522 to 9e92519 Compare October 14, 2022 23:35
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 725b6c7 to dc69cb3 Compare October 20, 2022 00:50
@jakebailey jakebailey changed the title Change build system to hereby Modernize localize script Oct 20, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 9e92519 to c2e8900 Compare October 20, 2022 00:50
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from dc69cb3 to bb59776 Compare October 20, 2022 01:25
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from f9f8e9e to a7d2107 Compare October 24, 2022 23:15
@jakebailey jakebailey changed the title Ensure ts object passed to plugins contains deprecatedCompat declarations Move compiler-debug into Debug namespace, which allows the compiler to be tree shaken Oct 24, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from e1ee5ae to 384ab90 Compare October 24, 2022 23:16
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from a7d2107 to 1f616d1 Compare October 25, 2022 02:25
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 384ab90 to 9f324c5 Compare October 25, 2022 02:25
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 1f616d1 to 393d0de Compare October 27, 2022 17:46
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 9f324c5 to 67d85a4 Compare October 27, 2022 17:47
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 393d0de to 540a735 Compare October 28, 2022 02:28
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 67d85a4 to 7360152 Compare October 28, 2022 02:29
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 540a735 to abb36fd Compare October 31, 2022 21:39
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 7360152 to 6aa7f3e Compare October 31, 2022 21:40
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from abb36fd to 9f30548 Compare November 2, 2022 00:50
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 6aa7f3e to 47028cb Compare November 2, 2022 00:50
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 9f30548 to 935be03 Compare November 2, 2022 17:01
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 47028cb to c2c6386 Compare November 2, 2022 17:02
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 935be03 to 51893a6 Compare November 2, 2022 19:52
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from c2c6386 to a524243 Compare November 2, 2022 19:52
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 51893a6 to 7e5b706 Compare November 6, 2022 21:53
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from a524243 to 08fe163 Compare November 6, 2022 21:53
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 7e5b706 to 3fa05c2 Compare November 6, 2022 21:59
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 08fe163 to 654a6e3 Compare November 6, 2022 21:59
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 3fa05c2 to 77eb926 Compare November 7, 2022 03:54
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 654a6e3 to 175fc44 Compare November 7, 2022 03:54
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from 77eb926 to df9c9f9 Compare November 7, 2022 19:28
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from 175fc44 to a6091c0 Compare November 7, 2022 19:28
@jakebailey jakebailey force-pushed the transform-stack-commit-30 branch from df9c9f9 to cf0b856 Compare November 7, 2022 21:39
…o 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).
@jakebailey jakebailey force-pushed the transform-stack-commit-31 branch from a6091c0 to 32515e4 Compare November 7, 2022 21:39
@jakebailey jakebailey closed this Nov 7, 2022
@jakebailey jakebailey deleted the transform-stack-commit-31 branch November 7, 2022 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant