Skip to content

fix(react): resolve default re-export bindings from imported identifiers#105

Merged
async3619 merged 1 commit intodevfrom
fix/default-reexport-binding
Mar 21, 2026
Merged

fix(react): resolve default re-export bindings from imported identifiers#105
async3619 merged 1 commit intodevfrom
fix/default-reexport-binding

Conversation

@async3619
Copy link
Copy Markdown
Owner

Summary

  • Fix export default ImportedIdentifier pattern not being recognized as a re-export, causing components imported through barrel files to be missing from the react usage tree
  • Pass importsByLocalName and reExportBindingsByName into collectDefaultExport so it can fall back to creating a re-export binding when the exported identifier is not a locally defined symbol

Details

When a barrel file re-exports like:

import Footer from './Footer'
export default Footer

collectDefaultExport called addExportBinding('Footer', 'default', symbolsByName, ...), but Footer only existed in importsByLocalName, not symbolsByName. addExportBinding silently returned, and the default export was never registered — making <Footer /> invisible in the tree.

The fix adds a fallback: if addExportBinding didn't register anything (the identifier isn't local), check importsByLocalName and create a reExportBinding instead.

Test plan

  • All existing unit tests pass (56/56)
  • All existing e2e tests pass (55/55)
  • Manually verified: <Footer /> now appears in TransparentLayout tree when analyzing a real Next.js project

Closes #103

🤖 Generated with Claude Code

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>
@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq bot commented Mar 21, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing fix/default-reexport-binding (dc77372) with dev (e9643e2)

Open in CodSpeed

@async3619 async3619 merged commit 2e97e90 into dev Mar 21, 2026
3 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 21, 2026
## [1.1.1-dev.1](v1.1.0...v1.1.1-dev.1) (2026-03-21)

### Bug Fixes

* **react:** resolve default re-export bindings from imported identifiers ([#105](#105)) ([2e97e90](2e97e90)), closes [#103](#103)
@async3619
Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 1.1.1-dev.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.79%. Comparing base (e9643e2) to head (dc77372).
⚠️ Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
src/analyzers/react/bindings.ts 14.28% 6 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

react: component missing when imported through barrel re-export

1 participant