feat: report star re-exports on both import and export sides#215
Open
BridgeAR wants to merge 1 commit into
Open
feat: report star re-exports on both import and export sides#215BridgeAR wants to merge 1 commit into
BridgeAR wants to merge 1 commit into
Conversation
`export * from 'module'` is both a dependency edge and a re-export, but only the specifier was surfaced, typed identically to a side-effect `import 'module'`. Consumers could not tell the two apart without a regex over the source. 1. A new import type `StaticReexportStar = 8` marks the specifier of a plain `export * from 'x'`, distinguishing it from a side-effect `import 'x'` (type `1`), which is otherwise the same shape. 2. The export side reports the name `*` for a plain `export *`, its name span pointing at the literal `*` and its statement range matching the import's, so the two halves correlate. `export * as ns from 'x'` is unchanged. import-in-the-middle can drop the per-statement regex it runs to recover star re-exports and read `imported.t === 8` instead — the information the lexer already had while tokenizing. Refs: guybedford#76 Refs: nodejs/import-in-the-middle#259
BridgeAR
marked this pull request as ready for review
July 1, 2026 17:20
guybedford
approved these changes
Jul 2, 2026
guybedford
left a comment
Owner
There was a problem hiding this comment.
I'm happy to land this. Formally speaking though it is a breaking change unless we make it export metadata-based.
If we wanted a non-breaking version, RollupJS used to have an internal convention here (not sure if it still does) of making the export name itself *module. That is, if the export name begins with * then it is a star export from that module.
It's a hack and this approach is better though. Would just be nice to bunch with any other major changes for a 3.x.
Owner
|
If we're doing a break for 3.x, making exports return an object would likely be smarter then as well. |
Contributor
Author
|
I think having v3 makes most sense |
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 * from 'module'is both a dependency edge and a re-export, but the lexer surfaced only the specifier — typed identically to a side-effectimport 'module', so consumers cannot tell the two apart without a regex over the source. This reports the star on both sides:StaticReexportStar = 8marks the specifier of a plainexport * from 'x', distinguishing it from a side-effectimport 'x'(type1), which is otherwise the same shape.*for a plainexport *, its name span pointing at the literal*and its statement range matching the import's, so the two halves correlate.export * as ns from 'x'is unchanged — it already reportsns.Why
import-in-the-middle currently runs a regex over every re-export statement to recover the star re-exports the lexer dropped. Typing the specifier lets it drop that regex and read
imported.t === 8directly — the information the lexer already had while tokenizing, at no extra scan cost.Test plan
npm run build && npm test(wasm + asm.js builds)Export star reexport*cases intest/_unit.cjscover type8vs side-effect1, export name*, comments between tokens, facade + module-syntax detection, and statement-range correlation.Refs: #76
Refs: nodejs/import-in-the-middle#259