feat: treeshake namespace aliases via non-reassigned bindings#9578
Draft
IWANABETHATGUY wants to merge 1 commit into
Draft
feat: treeshake namespace aliases via non-reassigned bindings#9578IWANABETHATGUY wants to merge 1 commit into
IWANABETHATGUY wants to merge 1 commit into
Conversation
IWANABETHATGUY
marked this pull request as draft
May 27, 2026 02:24
IWANABETHATGUY
force-pushed
the
05-27-feat_treeshake_ns_alias
branch
from
May 27, 2026 02:25
779eacf to
626e391
Compare
Member
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label graphite: merge-when-ready to this PR to add it to 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. |
3 tasks
IWANABETHATGUY
force-pushed
the
05-27-feat_treeshake_ns_alias
branch
2 times, most recently
from
May 27, 2026 02:39
4ceff1a to
41d7aff
Compare
Extend the `export default <namespace>` re-export tree-shaking to named variable exports of the form `export <kind> res = ns;` where `ns` is an `import * as ns` local and `res` is non-reassigned. The reassignment guard is driven by the existing `SymbolRefFlags::IsNotReassigned`, so `let`/`var` qualify whenever they have no write references. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
IWANABETHATGUY
force-pushed
the
05-27-feat_treeshake_ns_alias
branch
from
May 27, 2026 02:46
41d7aff to
e326b9e
Compare
This was referenced Jun 15, 2026
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.

Summary
export default <namespace>re-exports #9574. Extends theexport default <namespace>re-export tree-shaking to named variable exports of the formexport <kind> res = ns;, wherensis animport * as nslocal.SymbolRefFlags::IsNotReassignedon the declared binding —let/varqualify whenever they have no write references, matching the safety property exactly.LocalExport[name].referencedis rewired to the namespace local. The re-export chain inbind_imports_and_exportsthen propagates downstream, enabling member-expression tree-shaking throughres.REPL repro that motivated this
Output before: full
api_exportsnamespace object + bothusedandunusedkept. Output after: collapses toconsole.log("used").Test plan
named_const_export_namespace— basic case from the REPL linknamed_const_export_namespace_member_write—res.obj.a = 2resolves through to the underlying binding, matchingdefault_export_namespace_member_writenamed_let_export_namespace—letwith no writes optimizes identically toconstnamed_let_export_namespace_reassigned—let res = api; res = {...}keeps the namespace and respects the post-reassignment value