-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: Split module exports into a local and global variant #20885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the module export system to distinguish between direct exports and re-exports, supporting better locality analysis for API graphs. The changes split exportsAs and getSourceNode into "direct" variants (local, ignoring re-exports) and non-direct variants (global, looking through re-exports).
- Added
exportsDirectlyAsandgetDirectSourceNodepredicates for local export analysis - Introduced
reExportsAsandgetReExportedSourceNodeinReExportDeclarationfor tracking re-exported values - Refactored type-only export handling and simplified
OriginalExportDeclaration
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| /** | ||
| * Holds if this re-export destination ultimately re-exports `v` (from another module) |
Copilot
AI
Nov 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "this re-export destination" but it should say "this re-export declaration" instead. The term "destination" is confusing here - the declaration is the source of the re-export, not the destination.
tausbn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! The uppercase E in ReExport kind of makes my eye twitch, but I'm not going to complain loudly about it. (I would prefer Reexport -- or Reëxport if we want to go full New Yorker.)
ExportDeclaration.getSourceNodeand.exportsAswere global because they look through re-exports.This PR splits these into a "direct" version that is local and ignores re-exports, and a non-direct version that is global and looks through re-exports.
One of the use-cases for the direct version is for API graphs to make a local over-approximation of the set of def-nodes we need, so that
API::Nodecan become local.