Skip to content

feat: install __r in runtime only if it wasn't yet provided#1714

Open
tjzel wants to merge 1 commit into
facebook:mainfrom
tjzel:@tjzel/entryPointRequire
Open

feat: install __r in runtime only if it wasn't yet provided#1714
tjzel wants to merge 1 commit into
facebook:mainfrom
tjzel:@tjzel/entryPointRequire

Conversation

@tjzel
Copy link
Copy Markdown

@tjzel tjzel commented May 14, 2026

Summary

I was thinking about the way of simplifying the amount of config required for the Bundle Mode, removing the need of using getModulesRunBeforeMainModule since it's an API difficult to integrate with (see expo/expo#43546) and removing the hack of throwing an error after an entry point is evaluated to block additional entry points, then proceed with a costly catch statement.

I came up with an idea that the runtime owner could install his own __r function outside of the bundle. Metro would then not override it but instead write its __r as __e if it were needed.

I think it's a better approach than relying on https://metrobundler.dev/docs/configuration/#getrunmodulestatement configuration, as it might again lead to merge issues etc. as for getModulesRunBeforeMainModule.

Changelog: [Feature] install __r in runtime only if it wasn't yet provided

Test plan

I added test cases to cover this feature.

@meta-cla meta-cla 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 May 14, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label May 14, 2026
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. 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.

1 participant