fix(react): resolve default re-export bindings from imported identifiers#105
Merged
fix(react): resolve default re-export bindings from imported identifiers#105
Conversation
When a barrel file re-exports an imported identifier as the default export (`import X from './X'; export default X`), the identifier only exists in `importsByLocalName`, not `symbolsByName`. The previous code silently dropped it, causing components like `<Footer />` to disappear from the react usage tree. Pass `importsByLocalName` and `reExportBindingsByName` into `collectDefaultExport` so it can fall back to creating a re-export binding when the identifier is not a locally defined symbol. Closes #103 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Owner
Author
|
🎉 This PR is included in version 1.1.1-dev.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #105 +/- ##
==========================================
- Coverage 68.95% 68.79% -0.16%
==========================================
Files 38 38
Lines 2216 2221 +5
Branches 712 714 +2
==========================================
Hits 1528 1528
- Misses 403 408 +5
Partials 285 285 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 ImportedIdentifierpattern not being recognized as a re-export, causing components imported through barrel files to be missing from the react usage treeimportsByLocalNameandreExportBindingsByNameintocollectDefaultExportso it can fall back to creating a re-export binding when the exported identifier is not a locally defined symbolDetails
When a barrel file re-exports like:
collectDefaultExportcalledaddExportBinding('Footer', 'default', symbolsByName, ...), butFooteronly existed inimportsByLocalName, notsymbolsByName.addExportBindingsilently returned, and the default export was never registered — making<Footer />invisible in the tree.The fix adds a fallback: if
addExportBindingdidn't register anything (the identifier isn't local), checkimportsByLocalNameand create areExportBindinginstead.Test plan
<Footer />now appears in TransparentLayout tree when analyzing a real Next.js projectCloses #103
🤖 Generated with Claude Code