-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: duplicate worklets code the smart way #6827
Merged
Merged
Conversation
This file contains 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
tjzel
force-pushed
the
@tjzel/worklets/restructure-worklets-source-sets
branch
from
January 20, 2025 17:33
b30c495
to
2634199
Compare
tjzel
force-pushed
the
@tjzel/worklets/duplicate-reanimated-code
branch
from
January 21, 2025 09:02
d723ecc
to
62c9488
Compare
…lets-source-sets' into @tjzel/worklets/duplicate-reanimated-code
…@tjzel/worklets/duplicate-reanimated-code
…@tjzel/worklets/duplicate-reanimated-code
tjzel
commented
Jan 28, 2025
...reanimated/android/src/externalWorklets/with/com/swmansion/reanimated/ReanimatedPackage.java
Outdated
Show resolved
Hide resolved
Base automatically changed from
@tjzel/worklets/restructure-worklets-source-sets
to
main
January 28, 2025 11:34
bartlomiejbloniarz
approved these changes
Jan 28, 2025
...nimated/android/src/externalWorklets/without/com/swmansion/reanimated/ReanimatedPackage.java
Outdated
Show resolved
Hide resolved
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 31, 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.
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 the transitional period of
react-native-worklets
coming as a separate package, Reanimated should work with or withoutreact-native-worklets
installed. This requires the code of Worklets to be present both inreact-native-reanimated
andreact-native-worklets
.This PR moves Worklets' files that were in Reanimated to
react-native-worklets
package and adds a script that makes hard links to these files. The linking happens during theyarn build
step ofreact-native-reanimated
- this guarantees thatreact-native-reanimated
would still work withoutreact-native-worklets
and that its' npm package would still contain all the necessary files.For Android some files had to be duplicated. This is because of codegen conflicts and namespace generation. However, that code is relatively small and put into respective source sets
externalWorklets/with
andexternalWorklets/without
.Also:
ReanimatedVersion.cpp/h
files back to Reanimated. We'll implement version checking for Worklets when we actually need it.yarn build
in Reanimated when necessary.react-native-worklets
inreact-native-reanimated
.react-native-worklets
for iOS.NativeWorkletsModuleSpec.ts
toNativeReaWorkletsModuleSpec.ts
to avoid codegen conflicts.DummyWorkletsModule
fromreact-native-worklets
since now it hasWorkletsModule
.Test plan
Run an Example with these changes.
Then do
yarn add react-native-worklets
incommon-app
(it will use workspace version by default) in the example directory and run it again.