Skip to content

Commit a1bad64

Browse files
aattolareact-native-bot
authored andcommitted
fix: exclusion of selectively disabled libraries from codegen generation (#51838)
Summary: PR #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: #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
1 parent 4c9490c commit a1bad64

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/react-native/scripts/codegen/__tests__/generate-artifacts-executor-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const packageJson = JSON.stringify({
7676
jsSrcsDir: '.',
7777
},
7878
libraryPath: '.',
79+
name: undefined,
7980
});
8081
});
8182

@@ -96,6 +97,7 @@ const packageJson = JSON.stringify({
9697
jsSrcsDir: '.',
9798
},
9899
libraryPath: rootPath,
100+
name: 'react-native',
99101
});
100102
});
101103

@@ -112,6 +114,7 @@ const packageJson = JSON.stringify({
112114
jsSrcsDir: '.',
113115
},
114116
libraryPath: myDependencyPath,
117+
name: 'react-native',
115118
});
116119
expect(libraries[1]).toEqual({
117120
config: {
@@ -120,6 +123,7 @@ const packageJson = JSON.stringify({
120123
jsSrcsDir: 'component/js',
121124
},
122125
libraryPath: myDependencyPath,
126+
name: 'my-component',
123127
});
124128
expect(libraries[2]).toEqual({
125129
config: {
@@ -128,6 +132,7 @@ const packageJson = JSON.stringify({
128132
jsSrcsDir: 'module/js',
129133
},
130134
libraryPath: myDependencyPath,
135+
name: 'my-module',
131136
});
132137
});
133138
});

packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ function extractLibrariesFromJSON(configFile, dependencyPath) {
216216
const config = configFile.codegenConfig;
217217
return [
218218
{
219+
name: configFile.name,
219220
config,
220221
libraryPath: dependencyPath,
221222
},
@@ -267,6 +268,7 @@ function printDeprecationWarningIfNeeded(dependency) {
267268
function extractLibrariesFromConfigurationArray(configFile, dependencyPath) {
268269
return configFile.codegenConfig.libraries.map(config => {
269270
return {
271+
name: config.name,
270272
config,
271273
libraryPath: dependencyPath,
272274
};

0 commit comments

Comments
 (0)