Skip to content

Resolve export * as ns re-exports under modern parsers#3250

Open
rasmi wants to merge 1 commit into
import-js:mainfrom
rasmi:export-star-as-fix
Open

Resolve export * as ns re-exports under modern parsers#3250
rasmi wants to merge 1 commit into
import-js:mainfrom
rasmi:export-star-as-fix

Conversation

@rasmi
Copy link
Copy Markdown
Contributor

@rasmi rasmi commented May 18, 2026

Fixes two pre-existing ExportAllDeclaration bugs that affect modern parsers (espree ES2020+, @babel/eslint-parser) but not babel-eslint. Extracted from #3230 (eslint v10 support) to make that PR cleaner.

Root cause

babel-eslint represents export * as ns from './mod' as ExportNamedDeclaration + ExportNamespaceSpecifier (a working code path), so the bug was latent. Modern parsers emit ExportAllDeclaration with exported, which hit two broken spots:

  • specifier.js: passed a string (specifier.source.value) to namespace.add(), which expects an AST node — so the namespace getter was never set up and ns didn't resolve. Fixed by defining the lazy getter directly, matching the existing ExportNamespaceSpecifier case.
  • visitor.js: export * as ns was unconditionally added to the star-export dependencies set, incorrectly flattening the target module's exports into the current one. Fixed by only adding to dependencies for plain export * (no as).

Tests

The included regression test covers the false negative: the namespace rule now correctly flags invalid deep references through export * as re-exports that were previously silently missed (fails on main, passes with the fix).

The false-positive symptoms #1834, #1883, #1845, #2002, #2289 ("errors after upgrading Babel") are resolved by the same change, but only reproduce with @babel/eslint-parser, which is introduced in #3230.

Fixes #2002, #1883, #1834, #1845, #2289.

@rasmi rasmi force-pushed the export-star-as-fix branch from de05c15 to 8860796 Compare May 18, 2026 03:11
@rasmi rasmi force-pushed the export-star-as-fix branch from 8860796 to 15dcddd Compare May 18, 2026 03:13
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.66%. Comparing base (395dfc9) to head (15dcddd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3250      +/-   ##
==========================================
+ Coverage   95.50%   95.66%   +0.16%     
==========================================
  Files          83       83              
  Lines        3693     3692       -1     
  Branches     1336     1334       -2     
==========================================
+ Hits         3527     3532       +5     
+ Misses        166      160       -6     

☔ 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.

@rasmi rasmi mentioned this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[export] incorrect report on export * as

1 participant