Skip to content

Fix renameTo changing exported names and re-exported specifiers - #757

Open
sebxt wants to merge 1 commit into
meta:mainfrom
sebxt:fix/renameto-export-specifiers
Open

sebxt wants to merge 1 commit into
meta:mainfrom
sebxt:fix/renameto-export-specifiers

Conversation

@sebxt

@sebxt sebxt commented Oct 20, 2026

Copy link
Copy Markdown

renameTo renamed both identifiers of an ExportSpecifier:

  • export { foo } became export { newFoo }, changing the module's exports.
  • export { foo as baz } from 'module' became export { newFoo as baz } from 'module', although that foo refers to the other module.

This change:

  • skips the exported identifier of a specifier;
  • skips specifiers of an export declaration that has a source;
  • when the local name of export { foo } is renamed, sets original = null on the specifier so recast reprints it as export { newFoo as foo }. Without this, recast patches the source range shared by local and exported and still prints export { newFoo }.

Test plan: added two tests to VariableDeclarator-test.js that rename an exported variable and a variable shadowed by re-exports, and compare the printed output. Both fail on main and pass with the change. yarn test passes. Includes a changeset.

Fixes #756

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc66d0e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
jscodeshift Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@sebxt is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

renameTo changes exported names and renames re-exports from other modules

1 participant