Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Expo's tree shaking crashes production with latest react-native-reanimated #41620

@RohovDmytro

Description

@RohovDmytro

Minimal reproducible example

https://github.com/RohovDmytro/expo-shaken-reanimated

Steps to reproduce

App crashes when tree shaken enabled. Not sure if its due to side effects in reanimated or due to unstable nature of tree shaking as a feature flag.

Steps to reproduce

There’s a problem with pairing expo’s unstable feature flags with latest react-native-reanimated version.

  1. New expo project

  2. Set up tree shaking via .env:

EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH=1
EXPO_UNSTABLE_TREE_SHAKING=1
EXPO_UNSTABLE_WEB_MODAL=1
  1. Add
yarn add react-native-reanimated@4.2.0 react-native-worklets@0.7.1x
  1. Wrap the App.js with an Animate.View component to make sure reanimated stays in the bundle.

  2. Build an Android release build.

  3. Crash:

{ [WorkletsError: [Worklets] Native part of Worklets doesn't seem to be initialized.

Environment

expo-env-info 2.0.8 environment info:
    System:
      OS: macOS 26.2
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 24.11.1 - ~/.nvm/versions/node/v24.11.1/bin/node
      Yarn: 1.22.15 - /usr/local/bin/yarn
      npm: 11.6.2 - ~/.nvm/versions/node/v24.11.1/bin/npm
      Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.16.2 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 25.2, iOS 26.2, macOS 26.2, tvOS 26.2, visionOS 26.2, watchOS 26.2
      Android SDK:
        API Levels: 33, 34, 35, 36
        Build Tools: 35.0.0, 36.0.0, 36.1.0
        System Images: android-31 | Google Play ARM 64 v8a
    IDEs:
      Android Studio: 2025.2 AI-252.27397.103.2522.14514259
      Xcode: 26.2/17C52 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~54.0.29 => 54.0.29 
      react: 19.1.0 => 19.1.0 
      react-native: 0.81.5 => 0.81.5 
    Expo Workflow: bare

Expo Doctor Diagnostics

✖ Check that packages match versions required by installed Expo SDK

⚠️ Minor version mismatches
package                  expected  found  
react-native-reanimated  ~4.1.1    4.2.0  
react-native-worklets    0.5.1     0.7.1  



2 packages out of date.
Advice:
Use 'npx expo install --check' to review and upgrade your dependencies.
To ignore specific packages, add them to "expo.install.exclude" in package.json. Learn more: https://expo.fyi/dependency-validation

2 checks failed, indicating possible issues with the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✋ on holdThis issue is accepted but prerequisites must be fulfilled first, or it's for an unstable feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions