Migrate from react-native-reanimated to react-native-worklets with backward compatibility#731
Conversation
|
I verified that those changes work correctly in the current E/App setup (reanimated3). Adhoc builds are here: Expensify/App#71973 I'll continue verifying the setup with reanimated v4 and worklets |
|
I also confirm that E/App with |
blazejkustra
left a comment
There was a problem hiding this comment.
Looks good to me (mostly reviewed the js part) 👌
| xcconfig = { | ||
| "OTHER_CFLAGS" => "$(inherited) -DREACT_NATIVE_MINOR_VERSION=#{react_native_minor_version}", | ||
| "HEADER_SEARCH_PATHS" => [ | ||
| "\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/apple\"", | ||
| "\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/Common/cpp\"", | ||
| "\"$(PODS_ROOT)/#{react_native_worklets_node_modules_dir_from_pods_root}/apple\"", | ||
| "\"$(PODS_ROOT)/#{react_native_worklets_node_modules_dir_from_pods_root}/Common/cpp\"", | ||
| ].join(' '), | ||
| } | ||
| if worklets_installed | ||
| xcconfig["OTHER_CFLAGS"] << " -DWORKLETS_INSTALLED=1" | ||
| end | ||
| s.xcconfig = xcconfig |
There was a problem hiding this comment.
Does it work if we modify s.xcconfig directly (without xcconfig variable)?
There was a problem hiding this comment.
Unfortunately not, I tried that at first but there was an error about modifying s.xcconfig
There was a problem hiding this comment.
Okay, alternatively we can just have other_cflags string variable and append to it instead of having xcconfig variable
|
@tomekzaw I tested it on Expensify main and on @blazejkustra PR with reanimated bump and confirm it works as expected. I think we're ready for merge! |
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the library from using react-native-reanimated to react-native-worklets while maintaining backward compatibility. The changes introduce compile-time detection of which worklets library is available and adapt the code accordingly.
- Updates type definitions to use locally-defined worklet types instead of importing from reanimated
- Adds conditional compilation flags and build configurations for both libraries
- Implements backward-compatible type casting and library detection
Reviewed Changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/parseExpensiMark.ts | Updates imports to use local WorkletFunction type with generic parameters |
| src/commonTypes.ts | Adds comprehensive worklet type definitions for both libraries |
| src/MarkdownTextInput.tsx | Updates imports and adds type casting for backward compatibility |
| package.json | Adds react-native-worklets as optional dependency while updating reanimated version |
| example/package.json | Updates dependency versions for both worklet libraries |
| example/babel.config.js | Adds conditional plugin selection based on available worklets library |
| cpp/RuntimeDecorator.cpp | Implements conditional compilation for different worklet extraction methods |
| cpp/MarkdownGlobal.h | Adds type alias for backward compatibility with ShareableWorklet |
| cpp/MarkdownGlobal.cpp | Updates function signatures to use SerializableWorklet type |
| apple/MarkdownParser.mm | Adds conditional compilation for worklet type declarations |
| android/src/main/cpp/CMakeLists.txt | Implements conditional build configuration for worklets libraries |
| android/build.gradle | Adds worklets detection and conditional dependency management |
| RNLiveMarkdown.podspec | Implements worklets library detection and conditional iOS configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Details
Related Issues
GH_LINK #726
Manual Tests
Linked PRs