From 2116a0e036530ca9743eb255b5dc18533cadfcd7 Mon Sep 17 00:00:00 2001 From: chrfalch Date: Fri, 11 Oct 2024 12:29:34 +0200 Subject: [PATCH 1/3] Removed a check that is no longer needed We've had some issue with monorepos when resolving the codegen config on Android in other libraries, and found that due to versions no longer in use we could now remove the version test in `react-native-config.js` and always return the component descriptor etc. (The monorepo issue was with using `require.main.require` which will resolve to the calling script and not the module) For reference, here is the same PR in @react-native-community/slider: https://github.com/callstack/react-native-slider/pull/657 --- react-native.config.js | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/react-native.config.js b/react-native.config.js index a1cfbff8..2b1309f7 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -1,27 +1,14 @@ -let supportsCodegenConfig = false; -try { - const rnCliAndroidVersion = require.main.require( - '@react-native-community/cli-platform-android/package.json', - ).version; - const [major] = rnCliAndroidVersion.split('.'); - supportsCodegenConfig = major >= 9; -} catch (e) { - // ignore -} - module.exports = { dependency: { platforms: { - android: supportsCodegenConfig - ? { - libraryName: 'safeareacontext', - componentDescriptors: [ - 'RNCSafeAreaProviderComponentDescriptor', - 'RNCSafeAreaViewComponentDescriptor', - ], - cmakeListsPath: 'src/main/jni/CMakeLists.txt', - } - : {}, + android: { + libraryName: 'safeareacontext', + componentDescriptors: [ + 'RNCSafeAreaProviderComponentDescriptor', + 'RNCSafeAreaViewComponentDescriptor', + ], + cmakeListsPath: 'src/main/jni/CMakeLists.txt', + }, macos: null, windows: null, }, From b9434af6a805a2dd606226d6fcb28c11f4316c10 Mon Sep 17 00:00:00 2001 From: chrfalch Date: Wed, 16 Oct 2024 13:24:05 +0200 Subject: [PATCH 2/3] cr: Reverted and simplified change after code review Removed previous change and made the `supportsCodegenConfig` variable true initially --- react-native.config.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/react-native.config.js b/react-native.config.js index 2b1309f7..2fbfdef2 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -1,16 +1,29 @@ +let supportsCodegenConfig = true; +try { + const rnCliAndroidVersion = require.main.require( + '@react-native-community/cli-platform-android/package.json', + ).version; + const [major] = rnCliAndroidVersion.split('.'); + supportsCodegenConfig = major >= 9; +} catch (e) { + // ignore +} + module.exports = { dependency: { platforms: { - android: { - libraryName: 'safeareacontext', - componentDescriptors: [ - 'RNCSafeAreaProviderComponentDescriptor', - 'RNCSafeAreaViewComponentDescriptor', - ], - cmakeListsPath: 'src/main/jni/CMakeLists.txt', - }, + android: supportsCodegenConfig + ? { + libraryName: 'safeareacontext', + componentDescriptors: [ + 'RNCSafeAreaProviderComponentDescriptor', + 'RNCSafeAreaViewComponentDescriptor', + ], + cmakeListsPath: 'src/main/jni/CMakeLists.txt', + } + : {}, macos: null, windows: null, }, }, -}; +}; \ No newline at end of file From 4f8b18a7ae858806343039df85a9132bfa853a16 Mon Sep 17 00:00:00 2001 From: chrfalch Date: Wed, 16 Oct 2024 13:24:47 +0200 Subject: [PATCH 3/3] revert: reverted commit - removed last line. --- react-native.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-native.config.js b/react-native.config.js index 2fbfdef2..160896e0 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -26,4 +26,4 @@ module.exports = { windows: null, }, }, -}; \ No newline at end of file +};