Skip to content

Commit

Permalink
Add @react-native/babel-plugin-codegen to @react-native/babel-preset (#…
Browse files Browse the repository at this point in the history
…38227)

Summary:
Pull Request resolved: #38227

X-link: facebook/metro#1023

This diff enables react-native/babel-plugin-codegen to react-native/babel-preset. This will enable static view configs generation for properly schematized native components.

Changelog: [General][Changed] - react-native/babel-plugin-codegen to react-native/babel-preset

Reviewed By: christophpurrer

Differential Revision: D46688516

fbshipit-source-id: ebecc5fd610ca4b86c55355879ad3fd36d51cae9
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Aug 1, 2023
1 parent a79cde6 commit 1c3b3a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/react-native-babel-preset/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native/babel-preset",
"version": "0.73.15",
"version": "0.73.16",
"description": "Babel preset for React Native applications",
"main": "src/index.js",
"repository": {
Expand Down Expand Up @@ -51,6 +51,7 @@
"@babel/plugin-transform-typescript": "^7.5.0",
"@babel/plugin-transform-unicode-regex": "^7.0.0",
"@babel/template": "^7.0.0",
"@react-native/babel-plugin-codegen": "*",
"babel-plugin-transform-flow-enums": "^0.0.2",
"react-refresh": "^0.4.0"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/react-native-babel-preset/src/configs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ const getPreset = (src, options) => {
]);
}

if (
!options.disableStaticViewConfigsCodegen &&
/\bcodegenNativeComponent</.test(src)
) {
extraPlugins.push([require('@react-native/babel-plugin-codegen')]);
}

if (!options || !options.disableImportExportTransform) {
extraPlugins.push(
[require('@babel/plugin-proposal-export-default-from')],
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "^0.73.15",
"@react-native/babel-preset": "^0.73.16",
"@react-native/eslint-config": "^0.73.0",
"@react-native/metro-config": "^0.73.0",
"@react-native/typescript-config": "^0.73.0",
Expand Down

0 comments on commit 1c3b3a0

Please sign in to comment.