Skip to content

feat: allow reuse of ReactRefresh instance#1513

Closed
jbroma wants to merge 4 commits intofacebook:mainfrom
callstack:feat/allow-reuse-of-react-refresh
Closed

feat: allow reuse of ReactRefresh instance#1513
jbroma wants to merge 4 commits intofacebook:mainfrom
callstack:feat/allow-reuse-of-react-refresh

Conversation

@jbroma
Copy link
Contributor

@jbroma jbroma commented Jun 4, 2025

Summary

Part of #1480

This PR enables reusing ReactRefresh instance across multiple module systems (like in MF for Metro). To achieve this following changes were made:

  • - added __METRO_GLOBAL_PREFIX__ to moduleId in RefreshRuntime.register() calls
  • - added __METRO_GLOBAL_PREFIX__ to moduleId registerExportsForReactRefresh() calls
  • - added a check for global[global.__METRO_GLOBAL_PREFIX__ + '__ReactRefresh'] in requireRefresh implementation

__METRO_GLOBAL_PREFIX__ and global.__METRO_GLOBAL_PREFIX__ differ from each other when multiple module systems are used - in context of Module Federation, the first one would refer to the local prefix defined at the top of the bundle, while the other always refers to the one coming from the Host

Changelog: [Feature] Allow reuse of React Refresh instance across multiple module systems

Test plan

TBD

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 4, 2025
@jbroma jbroma marked this pull request as ready for review June 5, 2025 16:09
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 5, 2025
@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@robhogan merged this pull request in c8de651.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants