Skip to content

worklets plugin: allow react-native imports in bundle mode#9213

Open
hannojg wants to merge 1 commit intosoftware-mansion:mainfrom
hannojg:hannojg/allow-react-native-worklet-imports
Open

worklets plugin: allow react-native imports in bundle mode#9213
hannojg wants to merge 1 commit intosoftware-mansion:mainfrom
hannojg:hannojg/allow-react-native-worklet-imports

Conversation

@hannojg
Copy link
Copy Markdown
Contributor

@hannojg hannojg commented Apr 5, 2026

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 to disallowRNImports() 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 --runInBand
  • yarn workspace react-native-worklets type:check:src:native

@hannojg hannojg changed the title [codex] allow react-native imports in bundle mode worklets plugin: allow react-native imports in bundle mode Apr 5, 2026
@hannojg hannojg marked this pull request as ready for review April 5, 2026 16:55
@MatiPl01 MatiPl01 requested a review from tjzel April 7, 2026 06:22
@tjzel tjzel self-assigned this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants