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(babel-preset-expo): auto add reanimated babel plugin when available #23798

Merged
merged 8 commits into from Aug 2, 2023

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Aug 2, 2023

Why

One less thing to think about. However, installing the package would mean you need to magically know about invalidating the Metro Babel cache. To account for this the expo/metro-config will now auto-invalidate when the reanimated version changes. This invalidation also solves another common issue where the worklet format changes between versions.

Test Plan

  • Added a babel test to ensure duplicates don't break the worklet format.
  • Manually tested by packing babel-preset-expo and installing a tabs@49 template. If you install react-native-reanimated, then restart the server, worklets will be transpiled.

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Aug 2, 2023
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Aug 2, 2023
Copy link
Member

@ide ide left a comment

Choose a reason for hiding this comment

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

Is there ever a case where it is necessary to opt-out without removing react-native-reanimated, such as in a monorepo where another workspace package depends on react-native-reanimated?

@EvanBacon
Copy link
Contributor Author

@ide users can pass reanimated: false to disable the feature. The reanimated plugin will add time, but it seemingly doesn't do anything unless the reanimated syntax is used. I would imagine that no one else is using "worklet" directives in the ecosystem.

@EvanBacon EvanBacon merged commit 421d95b into main Aug 2, 2023
9 of 10 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/babel-preset-expo/auto-add-reanimated branch August 2, 2023 21:02
],
```

After you add the Babel plugin, restart your development server and clear the bundler cache: `npx expo start --clear`.
Copy link
Member

Choose a reason for hiding this comment

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

we should probably add something here to indicate that you can remove the reanimated babel plugin that we automatically add, and link to the babel-preset-expo readme or docs for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants