Skip to content

proposal: RCTBundleConsumer interface #50788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tjzel
Copy link
Contributor

@tjzel tjzel commented Apr 17, 2025

Summary:

With the development of react-native-worklets library I want to align it more with the tools inside React Native ecosystem and reduce the amount of hacks needed to provide multithreading JavaScript solutions. One of the steps there is to obtain multi-threading (byte)code via Metro, instead of Babel tricks and evalWithSourceMap. For this sake it would be very handy to have an interface a Turbo Module could implement, that would allow it to get the bundle and all hot-reload updates. This would also benefit other libraries that are featuring multi-threading JavaScript.

The changes in this PR are only to demonstrate the PoC of iOS RCTBundleConsumer (or any other name you'd find suitable). The real implementation should probably base on event handlers and more elaborate constructions instead of a simple property, to support hot-reloads and other cases.

Please let me know if this is a feature you find acceptable within the ecosystem or if such feature already exists in some form - I know there's [self.bundle.delegate loadBundleAtUrl:...] but I don't think it applies for this use case and if it's considered to be a part of the public API.

Changelog:

[GENERAL] [ADDED] - Add RCTBundleConsumer interface for TurboModules to access the JS bundle

Test Plan:

Implement a Turbo Module with @synthesize source = _source, use it in RNTester app and see that everything still works flawlessly.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Software Mansion Partner: Software Mansion Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Apr 17, 2025
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. p: Software Mansion Partner: Software Mansion Partner 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