[RN][Codegen] Better support filtering out non linked platforms (#48183)

This commit is contained in:
Riccardo Cipolleschi
2024-12-09 14:39:29 +00:00
committed by GitHub
parent 93e9d5794e
commit fcbcf80d1c
@@ -311,12 +311,27 @@ function findNotLinkedLibraries(projectRoot) {
Object.keys(rnConfig.dependencies).forEach(name => {
const dependency = rnConfig.dependencies[name];
let notLinkedPlatforms = [];
Object.keys(dependency.platforms).forEach(platform => {
// dependency.platforms might not be defined, as the format
// {
// "dependencies": {
// "dependency-name": {
// "root": "path/to/dependency",
// }
// }
// }
// is also supported.
// In this case, we assume that the library is linked to all platforms.
// We don't consider the case were `dependency-name.root` is equal to `null`, because that
// means that the library is not linked to the app at all, and in that case the dependency
// should be removed by the user.
dependency.platforms && Object.keys(dependency.platforms).forEach(platform => {
if (dependency.platforms[platform] == null) {
notLinkedPlatforms.push(platform);
}
});
notLinkedLibraries[name] = notLinkedPlatforms;
});
return notLinkedLibraries;
}