worklets plugin: allow react-native imports in bundle mode#9213
Open
hannojg wants to merge 1 commit intosoftware-mansion:mainfrom
Open
worklets plugin: allow react-native imports in bundle mode#9213hannojg wants to merge 1 commit intosoftware-mansion:mainfrom
hannojg wants to merge 1 commit intosoftware-mansion:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
In worklets bundle mode you have some good reasons to disallow any imports from react-native, which makes sense for the average user. I am trying to build something more custom with worklets right now, where i want to run certain code from react-native in my worklets in bundle mode.
Adding
workletizableModules: ["react-native"]will make the plugin include the code, but at runtime due todisallowRNImports()it will never work.This PR passes a global value at runtime if bundle mode &&
workletizableModules: ["react-native"]. If the user explicitly adds this, i feel like we should allow the imports. Let me know what you think?Alternatively we could also hide this behind a feature flag if that's preferred?
It would be awesome to allow RN code to work in worklets (for users that know what they are doing), otherwise i would always need to patch react-native-worklets :/
Test plan
I added unit tests for that:
yarn jest __tests__/plugin.test.ts --runInBandyarn workspace react-native-worklets type:check:src:native