refactor(packages/codegen): specify in TSDown plugin how many args to remove from call sites - #25970
Merged
Conversation
This was referenced Aug 21, 2026
Member
Author
This was referenced Aug 21, 2026
overlookmotel
marked this pull request as ready for review
August 22, 2026 00:07
Contributor
There was a problem hiding this comment.
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
removecount and use it to drop trailing call arguments. - Make
markWithMap*helpers no-op behindSOURCEMAPSguards 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.
This was referenced Aug 22, 2026
graphite-app
Bot
force-pushed
the
om/08-18-refactor_packages_codegen_simplify_tsdown_plugin
branch
2 times, most recently
from
August 22, 2026 09:35
75e0602 to
95f984b
Compare
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
August 22, 2026 09:35
33c99e4 to
acc5300
Compare
camc314
approved these changes
Aug 22, 2026
Contributor
Merge activity
|
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
camc314
force-pushed
the
om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites
branch
from
August 22, 2026 10:18
acc5300 to
dad6575
Compare
… 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
Bot
force-pushed
the
om/08-19-refactor_packages_codegen_specify_in_tsdown_plugin_how_many_args_to_remove_from_call_sites
branch
from
August 22, 2026 10:23
dad6575 to
4c65037
Compare
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 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.