proposal: RCTBundleConsumer interface #50788
Open
+50
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 andevalWithSourceMap
. 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.