Skip to content

refactor(packages/codegen): specify in TSDown plugin how many args to remove from call sites - #25970

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites
Aug 22, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Aug 21, 2026

Copy link
Copy Markdown
Member

Alter how functions where are not used in no-sourcemap builds get removed from the build.

Previously, the plugin explicitly replaced calls to these functions with void 0. Instead:

1. Add if (SOURCEMAPS) guards to these functions, so minifier sees that they're no-ops and removes the calls.
2. Remove arguments from their call sites, so nothing gets left over by minifier.

Additionally, remove the params from the function declarations themselves.

The table in plugin specifies how many arguments to remove for each function.

These change does not alter the output code - the same stuff gets removed, just by a different mechanism. But this change enables the next PR #25971.

overlookmotel commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the unmap_writes TSDown plugin to more precisely drop trailing arguments at mapped-write call sites in non-sourcemap builds, and updates the markWithMap* helpers so minification can eliminate the remaining no-op calls.

Changes:

  • Extend the plugin rewrite table with a remove count and use it to drop trailing call arguments.
  • Make markWithMap* helpers no-op behind SOURCEMAPS guards so calls can be removed by the minifier.
  • Update design documentation to reflect the new non-sourcemap behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/codegen/tsdown_plugins/unmap_writes.ts Add remove metadata and use it to trim call arguments; adjust transform behavior around renames.
packages/codegen/src-js/print/write.ts Guard markWithMap* helpers with SOURCEMAPS so they become removable no-ops in non-sourcemap builds.
packages/codegen/DESIGN.md Document the updated unmap_writes strategy for mark helpers and minifier removal.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/codegen/tsdown_plugins/unmap_writes.ts
Comment thread packages/codegen/tsdown_plugins/unmap_writes.ts
Comment thread packages/codegen/DESIGN.md
@graphite-app
graphite-app Bot force-pushed the om/08-18-refactor_packages_codegen_simplify_tsdown_plugin branch 2 times, most recently from 75e0602 to 95f984b Compare August 22, 2026 09:35
@graphite-app
graphite-app Bot force-pushed the om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites branch from 33c99e4 to acc5300 Compare August 22, 2026 09:35
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Aug 22, 2026

camc314 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Aug 22, 10:11 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 22, 10:12 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • Aug 22, 10:17 AM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.
  • Aug 22, 10:17 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 22, 10:18 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Aug 22, 10:22 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • Aug 22, 10:27 AM UTC: Merged by the Graphite merge queue.

@graphite-app
graphite-app Bot changed the base branch from om/08-18-refactor_packages_codegen_simplify_tsdown_plugin to graphite-base/25970 August 22, 2026 10:11
@graphite-app
graphite-app Bot changed the base branch from graphite-base/25970 to main August 22, 2026 10:16
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Aug 22, 2026
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Aug 22, 2026 — with Graphite App
@camc314
camc314 force-pushed the om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites branch from acc5300 to dad6575 Compare August 22, 2026 10:18
… remove from call sites (#25970)

Alter how functions where are not used in no-sourcemap builds get removed from the build.

Previously, the plugin explicitly replaced calls to these functions with `void 0`. Instead:

1\. Add `if (SOURCEMAPS)` guards to these functions, so minifier sees that they're no-ops and removes the calls.
2\. Remove arguments from their call sites, so nothing gets left over by minifier.

Additionally, remove the params from the function declarations themselves.

The table in plugin specifies how many arguments to remove for each function.

These change does not alter the output code - the same stuff gets removed, just by a different mechanism. But this change enables the next PR #25971.
@graphite-app
graphite-app Bot force-pushed the om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites branch from dad6575 to 4c65037 Compare August 22, 2026 10:23
@graphite-app
graphite-app Bot merged commit 4c65037 into main Aug 22, 2026
29 checks passed
@graphite-app
graphite-app Bot deleted the om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites branch August 22, 2026 10:27
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Aug 22, 2026
graphite-app Bot pushed a commit that referenced this pull request Aug 22, 2026
…rintNonNegativeFloat` (#25971)

Small optimization to no-sourcemap builds.

`printString` and `printNonNegativeFloat` receive `node` as their last param, but in no-sourcemap builds, all the code which uses `node` is removed anyway.

Use the mechanism added in #25970 to remove the `node` param from the function declarations, and the corresponding argument from all call sites. This avoids passing data into these functions pointlessly, freeing a register.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Sponsor
SponsoredKunjungi sekarang
Promo