You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/src/latest/docs/features/reanimated.mdx
+60-36Lines changed: 60 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,69 +2,93 @@ import { PackageManagerTabs } from '@theme';
2
2
3
3
# React Native Reanimated
4
4
5
-
Re.Pack provides first-class support for [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/) through a dedicated plugin that simplifies integration and optimizes build performance.
5
+
Re.Pack provides first-class support for [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/) through a dedicated plugin that simplifies integration and in some cases, optimizes your build performance.
6
6
7
-
:::warning This plugin is primarily intended for Rspack users.
7
+
:::info This plugin is primarily used to disable console warnings that are not relevant when bundling a React Native app.
8
8
9
-
The main purpose of this plugin is to limit the **build performance impact** of the `react-native-reanimated` babel plugin.
9
+
:::
10
10
11
-
If you're using webpack with `babel-loader`, you probably don't need this plugin. Instead, you should follow the [official Reanimated documentation](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-2-add-reanimateds-babel-plugin) and add the Reanimated Babel plugin directly to your `babel.config.js`:
11
+
## How it Works
12
12
13
-
```js
14
-
module.exports= {
15
-
presets: ["module:@react-native/babel-preset"],
16
-
plugins: ["react-native-reanimated/plugin"],
17
-
};
18
-
```
13
+
The Worklets Babel Plugin transforms your code so that it can run on the Worklet Runtimes. It looks for functions marked with a `'worklet';` directive and converts them into serializable objects.
19
14
20
-
:::
15
+
When using Rspack, the worklets babel plugin is executed via `babel-swc-loader`. The `ReanimatedPlugin` handles configuration and suppresses warnings that would otherwise appear during the build process.
21
16
22
-
## How It Works
17
+
## Installation
23
18
24
-
### The Problem
19
+
If you haven't already, install the `react-native-reanimated` package:
25
20
26
-
React Native Reanimated requires a special Babel plugin to transform your code, particularly functions marked with `'worklet'`.
27
-
This transformation is necessary but comes with a cost - the babel transformation can slow down your build process significantly
28
-
when applied to all files. With Rspack under the hood, we want to make sure that we use `babel-loader` only as a last resort.
-**Smart Detection**: Before running babel, we scan files for Reanimated keywords like `worklet`
35
-
-**Targeted Processing**: Only files containing these keywords go through the transformation
36
-
-**Performance Boost**: Everything else skips this heavy processing step
27
+
## Usage with Reanimated 4+
37
28
38
-
In simple terms: we make your builds faster by only doing the heavy Reanimated processing where it's actually needed.
29
+
For Reanimated 4 and above, the worklet transformation is handled by the `react-native-worklets/plugin` babel plugin.
39
30
40
-
:::note Credits
41
-
Shoutout to [Nate Wienert](https://x.com/natebirdman) who came up with a similar approach in [one.dev](https://one.dev) - his work was the inspiration for this plugin.
0 commit comments