Skip to content

Commit b528795

Browse files
authored
Fixed wrong usage of require when resolving supportsCodegenConfig in react-native.config.js (#657)
* Fixed wrong usage of require when resolving supportsCodegenConfig When resolving the version inside `react-native-config` which is used by the autolinking gradle tasks, the wrong use of require was used. This fix changes from using `require.main.require` -> `require`. The difference is that require.main.require resolves from the entry point (main script), while require resolves from the location of the current file. * Codereview: Removed test for code gen alltogether
1 parent e870106 commit b528795

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

package/react-native.config.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
1-
let supportsCodegenConfig = false;
2-
try {
3-
const rnCliAndroidVersion = require.main.require(
4-
'@react-native-community/cli-platform-android/package.json',
5-
).version;
6-
const [major] = rnCliAndroidVersion.split('.');
7-
supportsCodegenConfig = major >= 9;
8-
} catch (e) {
9-
// ignore
10-
}
11-
121
module.exports = {
132
dependency: {
143
platforms: {
15-
android: supportsCodegenConfig
16-
? {
17-
libraryName: 'RNCSlider',
18-
componentDescriptors: ["RNCSliderComponentDescriptor"],
19-
cmakeListsPath: 'src/main/jni/CMakeLists.txt',
20-
}
21-
: {},
4+
android: {
5+
libraryName: 'RNCSlider',
6+
componentDescriptors: ['RNCSliderComponentDescriptor'],
7+
cmakeListsPath: 'src/main/jni/CMakeLists.txt',
8+
},
229
},
2310
},
2411
};

0 commit comments

Comments
 (0)