Skip to content

Migrate from react-native-reanimated to react-native-worklets with backward compatibility#731

Merged
war-in merged 22 commits into
Expensify:mainfrom
war-in:war-in/migrate-to-worklets
Oct 14, 2025
Merged

Migrate from react-native-reanimated to react-native-worklets with backward compatibility#731
war-in merged 22 commits into
Expensify:mainfrom
war-in:war-in/migrate-to-worklets

Conversation

@war-in

@war-in war-in commented Oct 3, 2025

Copy link
Copy Markdown
Collaborator

Details

Related Issues

GH_LINK #726

Manual Tests

Linked PRs

Comment thread RNLiveMarkdown.podspec Outdated
Comment thread RNLiveMarkdown.podspec Outdated
Comment thread RNLiveMarkdown.podspec Outdated
Comment thread android/build.gradle Outdated
Comment thread src/parseExpensiMark.ts Outdated
Comment thread src/MarkdownTextInput.tsx Outdated
Comment thread src/MarkdownTextInput.tsx Outdated
Comment thread src/MarkdownTextInput.tsx Outdated
Comment thread package.json Outdated
Comment thread package.json Outdated
@war-in war-in requested a review from tomekzaw October 7, 2025 09:48
@war-in

war-in commented Oct 8, 2025

Copy link
Copy Markdown
Collaborator Author

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

@war-in

war-in commented Oct 8, 2025

Copy link
Copy Markdown
Collaborator Author

I also confirm that E/App with reanimatedv4 and react-native-worklets work fine with the code from this PR. Adhoc builds here: Expensify/App#69469 (comment)

@war-in war-in marked this pull request as ready for review October 8, 2025 09:27

@blazejkustra blazejkustra left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me (mostly reviewed the js part) 👌

Comment thread src/MarkdownTextInput.tsx Outdated
Comment thread RNLiveMarkdown.podspec
Comment thread RNLiveMarkdown.podspec Outdated
Comment thread RNLiveMarkdown.podspec Outdated
Comment thread RNLiveMarkdown.podspec Outdated
Comment thread RNLiveMarkdown.podspec Outdated
Comment thread RNLiveMarkdown.podspec
Comment on lines +41 to +51
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does it work if we modify s.xcconfig directly (without xcconfig variable)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately not, I tried that at first but there was an error about modifying s.xcconfig

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay, alternatively we can just have other_cflags string variable and append to it instead of having xcconfig variable

Comment thread RNLiveMarkdown.podspec
Comment thread android/src/main/cpp/CMakeLists.txt
Comment thread cpp/RuntimeDecorator.cpp Outdated
Comment thread src/MarkdownTextInput.tsx Outdated
@war-in

war-in commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator Author

@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!

tomekzaw
tomekzaw previously approved these changes Oct 14, 2025
Comment thread cpp/RuntimeDecorator.cpp Outdated
Comment thread cpp/RuntimeDecorator.cpp Outdated
Comment thread cpp/RuntimeDecorator.cpp Outdated
@war-in war-in merged commit e9dc87e into Expensify:main Oct 14, 2025
7 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/MarkdownTextInput.tsx
Comment thread RNLiveMarkdown.podspec
@os-botify

os-botify Bot commented Oct 14, 2025

Copy link
Copy Markdown
Contributor

🚀 Published to npm in 0.1.308 🎉

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.

4 participants