Skip to content

Commit

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

Summary:
X-link: facebook/metro#1078

Pull Request resolved: #39159

Source is not required for `getPreset` of `react-native/babel-preset`. There is a codition that adds `react-native/babel-plugin-codegen` to the preset only if source is passing certain regex. This condition fails if source is null, but that's wrong because the plugin may still be requred for this transformation even though source is not provided.
This diff changes the condition so the regexp tests source only if it is not null, and `react-native/babel-plugin-codegen` automatically added to the preset otherwise.
Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D48684443

fbshipit-source-id: 7cea69c91c0175ac0374d72e91f58e20fe75fd53
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Sep 14, 2023
1 parent 5bafef6 commit 59e6b11
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-native-babel-preset/src/configs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const getPreset = (src, options) => {

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

0 comments on commit 59e6b11

Please sign in to comment.