fix: exclusion of selectively disabled libraries from codegen generation (#51838)

Summary:
PR https://github.com/facebook/react-native/issues/51078 Implemented finding disabled libraries but the code (below) didn't actually filter any libraries out because destructured name is `undefined`. This pr adds the name to codegenEnabledLibraries so filtering would work.

```js
const libraries = codegenEnabledLibraries.filter(
  ({name}) => !disabledLibraries.includes(name),
);
```

## Changelog:

[IOS] [FIXED] - Skip codegen for selectively disabled libraries in react-native.config.js

Pull Request resolved: https://github.com/facebook/react-native/pull/51838

Test Plan:
1. Install a library that has the componentProvider field set in the codegen config (for example: react-native-safe-area-context and react-native-screens or see [reproducer](https://github.com/aattola/rn-codegen-exclude))
2. Exclude library with react-native.config.js
3. install pods / run codegen
4. Check that codegen actually excluded the specified dependencies from: `ios/build/generated/ios/RCTThirdPartyComponentsProvider.mm`

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76044622

Pulled By: cipolleschi

fbshipit-source-id: 9e70c2a263c750edb1ea95305c9e5e178e2ce8d8
This commit is contained in:
Leevi Aattola
2025-06-09 14:00:47 +00:00
committed by React Native Bot
parent 4c9490c702
commit a1bad641bc
2 changed files with 7 additions and 0 deletions
@@ -76,6 +76,7 @@ const packageJson = JSON.stringify({
jsSrcsDir: '.',
},
libraryPath: '.',
name: undefined,
});
});
@@ -96,6 +97,7 @@ const packageJson = JSON.stringify({
jsSrcsDir: '.',
},
libraryPath: rootPath,
name: 'react-native',
});
});
@@ -112,6 +114,7 @@ const packageJson = JSON.stringify({
jsSrcsDir: '.',
},
libraryPath: myDependencyPath,
name: 'react-native',
});
expect(libraries[1]).toEqual({
config: {
@@ -120,6 +123,7 @@ const packageJson = JSON.stringify({
jsSrcsDir: 'component/js',
},
libraryPath: myDependencyPath,
name: 'my-component',
});
expect(libraries[2]).toEqual({
config: {
@@ -128,6 +132,7 @@ const packageJson = JSON.stringify({
jsSrcsDir: 'module/js',
},
libraryPath: myDependencyPath,
name: 'my-module',
});
});
});
@@ -216,6 +216,7 @@ function extractLibrariesFromJSON(configFile, dependencyPath) {
const config = configFile.codegenConfig;
return [
{
name: configFile.name,
config,
libraryPath: dependencyPath,
},
@@ -267,6 +268,7 @@ function printDeprecationWarningIfNeeded(dependency) {
function extractLibrariesFromConfigurationArray(configFile, dependencyPath) {
return configFile.codegenConfig.libraries.map(config => {
return {
name: config.name,
config,
libraryPath: dependencyPath,
};