Skip to content

Commit 1fdb732

Browse files
authored
chore: update readme and bump worklets (#4)
1 parent 4d9de30 commit 1fdb732

4 files changed

Lines changed: 79 additions & 16 deletions

File tree

README.md

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ yarn add react-native-streamdown
2828
yarn add react-native-enriched-markdown react-native-worklets remend
2929
```
3030

31-
| Package | Version |
32-
| -------------------------------- | ----------------------------- |
33-
| `react-native-enriched-markdown` | `0.4.0` |
34-
| `react-native-worklets` | `0.8.0-bundle-mode-preview-2` |
35-
| `remend` | `1.2.2` |
31+
| Package | Version |
32+
| -------------------------------- | ------------ |
33+
| `react-native-enriched-markdown` | `0.4.0` |
34+
| `react-native-worklets` | `0.8.0-rc.0` |
35+
| `remend` | `1.2.2` |
3636

3737
---
3838

@@ -42,7 +42,31 @@ yarn add react-native-enriched-markdown react-native-worklets remend
4242

4343
### 1. `babel.config.js` — configure Worklets Babel plugin
4444

45-
`react-native-streamdown` requires special options to be added to the Worklets Babel plugin config in `babel.config.js`:
45+
`react-native-streamdown` requires special options to be added to the Worklets Babel plugin config in `babel.config.js`, namely `bundleMode: true` and `workletizableModules: ['remend']`. Your final config could look like this:
46+
47+
#### Expo
48+
49+
```js
50+
module.exports = function (api) {
51+
api.cache(true);
52+
53+
return {
54+
presets: ['babel-preset-expo'],
55+
plugins: [
56+
[
57+
'react-native-worklets/plugin',
58+
{
59+
bundleMode: true,
60+
// other options...
61+
workletizableModules: ['remend'], // add this line
62+
},
63+
],
64+
],
65+
};
66+
};
67+
```
68+
69+
#### React Native CLI
4670

4771
```js
4872
const workletsPluginOptions = {
@@ -58,6 +82,45 @@ const workletsPluginOptions = {
5882

5983
`react-native-worklets` Bundle Mode generates files on the fly that might not be tracked by Metro in some monorepo setups. It might also shadow your resolving function. If you're running into issues with module resolution, you need to add the following to your `metro.config.js`:
6084

85+
#### Expo
86+
87+
```js
88+
const { getDefaultConfig } = require('expo/metro-config');
89+
const {
90+
getBundleModeMetroConfig,
91+
} = require('react-native-worklets/bundleMode');
92+
93+
let config = getDefaultConfig(__dirname);
94+
95+
// Watch the .worklets/ output directory
96+
config.watchFolders.push(
97+
require('path').resolve(
98+
__dirname,
99+
'node_modules/react-native-worklets/.worklets'
100+
)
101+
);
102+
103+
// Resolve react-native-worklets/.worklets/* via the Bundle Mode resolver
104+
const defaultResolver = config.resolver.resolveRequest;
105+
106+
config = getBundleModeMetroConfig(config);
107+
108+
config.resolver.resolveRequest = (context, moduleName, platform) => {
109+
if (moduleName.startsWith('react-native-worklets/.worklets/')) {
110+
return bundleModeMetroConfig.resolver.resolveRequest(
111+
context,
112+
moduleName,
113+
platform
114+
);
115+
}
116+
return defaultResolver(context, moduleName, platform);
117+
};
118+
119+
module.exports = config;
120+
```
121+
122+
#### React Native CLI
123+
61124
```js
62125
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
63126
const { bundleModeMetroConfig } = require('react-native-worklets/bundleMode');

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"react-native-enriched-markdown": "0.4.0",
1616
"react-native-safe-area-context": "^5.7.0",
1717
"react-native-streamdown": "*",
18-
"react-native-worklets": "0.8.0-bundle-mode-preview-2",
18+
"react-native-worklets": "0.8.0-rc.0",
1919
"remend": "1.2.2"
2020
},
2121
"devDependencies": {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"react-native-builder-bob": "^0.40.18",
8282
"react-native-enriched-markdown": "0.4.0",
8383
"react-native-sse": "1.2.1",
84-
"react-native-worklets": "0.8.0-bundle-mode-preview-2",
84+
"react-native-worklets": "0.8.0-rc.0",
8585
"release-it": "^19.0.4",
8686
"remend": "1.2.2",
8787
"turbo": "^2.5.6",
@@ -91,7 +91,7 @@
9191
"react": "*",
9292
"react-native": "*",
9393
"react-native-enriched-markdown": "0.4.0",
94-
"react-native-worklets": "0.8.0-bundle-mode-preview-2",
94+
"react-native-worklets": "0.8.0-rc.0",
9595
"remend": "1.2.2"
9696
},
9797
"workspaces": [

yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10707,7 +10707,7 @@ __metadata:
1070710707
react-native-monorepo-config: "npm:^0.3.3"
1070810708
react-native-safe-area-context: "npm:^5.7.0"
1070910709
react-native-streamdown: "npm:*"
10710-
react-native-worklets: "npm:0.8.0-bundle-mode-preview-2"
10710+
react-native-worklets: "npm:0.8.0-rc.0"
1071110711
remend: "npm:1.2.2"
1071210712
languageName: unknown
1071310713
linkType: soft
@@ -10738,7 +10738,7 @@ __metadata:
1073810738
react-native-builder-bob: "npm:^0.40.18"
1073910739
react-native-enriched-markdown: "npm:0.4.0"
1074010740
react-native-sse: "npm:1.2.1"
10741-
react-native-worklets: "npm:0.8.0-bundle-mode-preview-2"
10741+
react-native-worklets: "npm:0.8.0-rc.0"
1074210742
release-it: "npm:^19.0.4"
1074310743
remend: "npm:1.2.2"
1074410744
turbo: "npm:^2.5.6"
@@ -10747,14 +10747,14 @@ __metadata:
1074710747
react: "*"
1074810748
react-native: "*"
1074910749
react-native-enriched-markdown: 0.4.0
10750-
react-native-worklets: 0.8.0-bundle-mode-preview-2
10750+
react-native-worklets: 0.8.0-rc.0
1075110751
remend: 1.2.2
1075210752
languageName: unknown
1075310753
linkType: soft
1075410754

10755-
"react-native-worklets@npm:0.8.0-bundle-mode-preview-2":
10756-
version: 0.8.0-bundle-mode-preview-2
10757-
resolution: "react-native-worklets@npm:0.8.0-bundle-mode-preview-2"
10755+
"react-native-worklets@npm:0.8.0-rc.0":
10756+
version: 0.8.0-rc.0
10757+
resolution: "react-native-worklets@npm:0.8.0-rc.0"
1075810758
dependencies:
1075910759
"@babel/plugin-transform-arrow-functions": "npm:7.27.1"
1076010760
"@babel/plugin-transform-class-properties": "npm:7.27.1"
@@ -10773,7 +10773,7 @@ __metadata:
1077310773
"@react-native/metro-config": "*"
1077410774
react: "*"
1077510775
react-native: "*"
10776-
checksum: 10c0/9f04abb94bb88687aa225381d6239eddad80f0ce95279e87956b159b3be35c05dbba7114b1f790f5028bf054dda2bcad5484fe460e664bd50690fae6880f69db
10776+
checksum: 10c0/e349a12dd7a86d29fec605cff83bab5a949d503988dc1c0eb2bcfbb2ce720afe8e2a5e1652225963b576255d85d7cdc7d46ff32507719005f28c7b45d0bb7c0c
1077710777
languageName: node
1077810778
linkType: hard
1077910779

0 commit comments

Comments
 (0)