Skip to content

Commit fcbcf80

Browse files
authored
[RN][Codegen] Better support filtering out non linked platforms (#48183)
1 parent 93e9d57 commit fcbcf80

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,27 @@ function findNotLinkedLibraries(projectRoot) {
311311
Object.keys(rnConfig.dependencies).forEach(name => {
312312
const dependency = rnConfig.dependencies[name];
313313
let notLinkedPlatforms = [];
314-
Object.keys(dependency.platforms).forEach(platform => {
314+
315+
// dependency.platforms might not be defined, as the format
316+
// {
317+
// "dependencies": {
318+
// "dependency-name": {
319+
// "root": "path/to/dependency",
320+
// }
321+
// }
322+
// }
323+
// is also supported.
324+
// In this case, we assume that the library is linked to all platforms.
325+
// We don't consider the case were `dependency-name.root` is equal to `null`, because that
326+
// means that the library is not linked to the app at all, and in that case the dependency
327+
// should be removed by the user.
328+
dependency.platforms && Object.keys(dependency.platforms).forEach(platform => {
315329
if (dependency.platforms[platform] == null) {
316330
notLinkedPlatforms.push(platform);
317331
}
318332
});
319333
notLinkedLibraries[name] = notLinkedPlatforms;
334+
320335
});
321336
return notLinkedLibraries;
322337
}

0 commit comments

Comments
 (0)