Skip to content
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

feat(Worklets): JS code duplication #6921

Merged
merged 37 commits into from
Jan 31, 2025
Merged

Conversation

tjzel
Copy link
Collaborator

@tjzel tjzel commented Jan 22, 2025

Summary

In this PR I'm moving the WorkletsModule part of the JS code to react-native-worklets. Reanimated would still have those files duplicated via a mechanism introduced in #6827.
Now in Reanimated all worklets code must be acquired via a special WorkletsResolver module. This is a temporary solution and will be dropped once we require react-native-worklets as a mandatory dependency for react-native-reanimated.

  • Added a workaround so that in our monorepo react-native-worklets wouldn't be used in the app even though it's not a dependency.
  • Added an ESLint rule that enforces imports from WorkletsResolver.
  • I duplicated PlatformChecker.ts explicitly in react-native-worklets. This file is small and stable so I don't consider this to be an issue. We can think of some better solution once the package is more polished.
  • Split some types from commonTypes.ts between packages.

Test plan

Fabric example should work with & without react-native-worklets installed. You can check using the debugger that always the correct instance of Worklets' JavaScript code is used.

@tjzel tjzel changed the title refactor: duplicatable code feat(Worklets): duplicate Worklets JS code in Worklets Jan 22, 2025
Base automatically changed from @tjzel/worklets/duplicate-reanimated-code to main January 29, 2025 13:42
@tjzel tjzel changed the title feat(Worklets): duplicate Worklets JS code in Worklets feat(Worklets): JS code duplication Jan 29, 2025
@tjzel tjzel marked this pull request as ready for review January 29, 2025 17:51
@tjzel tjzel added this pull request to the merge queue Jan 31, 2025
Merged via the queue into main with commit 939e5fd Jan 31, 2025
19 checks passed
@tjzel tjzel deleted the @tjzel/worklets/duplicate-javascript branch January 31, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants