Skip to content

Commit 7bd206b

Browse files
authored
feat(Worklets): expose plugin options type (#8632)
## Summary Now the users can have typed configs with TSDoc and more. Our users can now do ```js /** @type {import('react-native-worklets/plugin').PluginOptions} */ const workletOptions = { // auto-suggestions here 🚀 }; ``` ## Test plan CI
1 parent 186fd16 commit 7bd206b

File tree

19 files changed

+184
-53
lines changed

19 files changed

+184
-53
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
/.yarn/plugins/**/* binary=true
44
/packages/eslint-plugin-reanimated/index.js linguist-generated=true
55
/packages/eslint-plugin-reanimated/types/**/* linguist-generated=true
6+
/packages/react-native-worklets/plugin/index.js linguist-generated=true
7+
/packages/react-native-worklets/plugin/index.d.ts linguist-generated=true

apps/fabric-example/babel.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
/** @type {import('react-native-worklets/plugin').PluginOptions} */
2+
const workletsPluginOptions = {
3+
// Uncomment the next line to enable bundle mode.
4+
// bundleMode: true,
5+
};
6+
17
/** @type {import('@babel/core').TransformOptions} */
28
module.exports = {
39
presets: ['module:@react-native/babel-preset'],
410
plugins: [
5-
[
6-
'react-native-worklets/plugin',
7-
{
8-
// Uncomment the next line to enable bundle mode.
9-
// bundleMode: true,
10-
},
11-
],
11+
['react-native-worklets/plugin', workletsPluginOptions],
1212
[
1313
'module-resolver',
1414
{

apps/macos-example/babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/** @type {import('react-native-worklets/plugin').PluginOptions} */
2+
const workletsPluginOptions = {};
3+
14
/** @type {import('@babel/core').TransformOptions} */
25
module.exports = {
36
presets: ['module:@react-native/babel-preset'],
@@ -12,6 +15,6 @@ module.exports = {
1215
extensions: ['.js', '.jsx', '.ts', '.tsx'],
1316
},
1417
],
15-
'react-native-worklets/plugin',
18+
['react-native-worklets/plugin', workletsPluginOptions],
1619
],
1720
};

apps/next-example/babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/** @type {import('react-native-worklets/plugin').PluginOptions} */
2+
const workletsPluginOptions = {};
3+
14
/** @type {import('@babel/core').TransformOptions} */
25
module.exports = {
36
presets: ['next/babel'],
@@ -13,6 +16,6 @@ module.exports = {
1316
},
1417
},
1518
],
16-
'react-native-worklets/plugin',
19+
['react-native-worklets/plugin', workletsPluginOptions],
1720
],
1821
};

apps/tvos-example/babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/** @type {import('react-native-worklets/plugin').PluginOptions} */
2+
const workletsPluginOptions = {};
3+
14
/** @type {import('@babel/core').TransformOptions} */
25
module.exports = {
36
presets: ['module:@react-native/babel-preset'],
4-
plugins: ['react-native-worklets/plugin'],
7+
plugins: [['react-native-worklets/plugin', workletsPluginOptions]],
58
};

apps/web-example/babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/** @type {import('react-native-worklets/plugin').PluginOptions} */
2+
const workletsPluginOptions = {};
3+
14
/** @type {import('@babel/core').ConfigFunction} */
25
module.exports = function (api) {
36
const plugins = [
@@ -18,7 +21,7 @@ module.exports = function (api) {
1821
if (disableBabelPlugin) {
1922
console.log('Starting Web example without Babel plugin.');
2023
} else {
21-
plugins.push('react-native-worklets/plugin');
24+
plugins.push(['react-native-worklets/plugin', workletsPluginOptions]);
2225
}
2326

2427
return {

packages/react-native-reanimated/babel.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/** @type {import('react-native-worklets/plugin').PluginOptions} */
2+
const workletsPluginOptions = { disableInlineStylesWarning: true };
3+
14
/** @type {import('@babel/core').TransformOptions} */
25
module.exports = {
36
presets: [
@@ -12,7 +15,5 @@ module.exports = {
1215
'@babel/preset-typescript',
1316
'module:@react-native/babel-preset',
1417
],
15-
plugins: [
16-
['react-native-worklets/plugin', { disableInlineStylesWarning: true }],
17-
],
18+
plugins: [['react-native-worklets/plugin', workletsPluginOptions]],
1819
};

packages/react-native-reanimated/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"compatibility.json",
6363
"mock.js",
6464
"plugin/index.js",
65+
"plugin/index.d.ts",
6566
"metro-config",
6667
"!**/__tests__",
6768
"!**/__fixtures__",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type { PluginOptions } from 'react-native-worklets/plugin/';

packages/react-native-worklets/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"scripts/worklets_utils.rb",
105105
"scripts/validate-react-native-version.js",
106106
"plugin/index.js",
107+
"plugin/index.d.ts",
107108
"*.podspec",
108109
"react-native.config.js",
109110
"!apple/build",

0 commit comments

Comments
 (0)