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

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

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
Comment on lines -72 to -76
- name: Use external worklets
if: ${{ inputs.use-external-worklets == 'true' }}
working-directory: ${{ env.COMMON_APP_DIR }}
run: yarn add react-native-worklets@workspace:"*"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how things keep duplicating when I rebase 😭

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(((

@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
Comment on lines -72 to -76
- name: Use external worklets
if: ${{ inputs.use-external-worklets == 'true' }}
working-directory: ${{ env.COMMON_APP_DIR }}
run: yarn add react-native-worklets@workspace:"*"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(((

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