From 6104ccdc6ef89c2d4da25e60dcc55d73038e023f Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Mon, 9 Jun 2025 16:13:46 -0700 Subject: [PATCH] Correct the excludePlatforms logic in combining schema step of Codegen (#51910) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51910 **Changelog:** [Android] [Fixed] - Fix combining schema in Codegen process to exclude platforms correctly Discovered an issue with how we are excluding platforms in processing codegen schema. `excludedPlatforms` is a field on `OptionsShape` part of `ComponentShape` not Module https://www.internalfb.com/code/fbsource/[153d78d4cd5d0fa652e5a0919bcdb26f32d0945e]/xplat/js/react-native-github/packages/react-native-codegen/src/CodegenSchema.js?lines=112 Hence for components modifying the script to iterate over component and for then exclude accordingly based on `platform`. Reviewed By: cipolleschi Differential Revision: D76158851 fbshipit-source-id: 791ec12d068794e36f34da7419082887483ce6c5 --- .../src/cli/combine/combine-schemas-cli.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/react-native-codegen/src/cli/combine/combine-schemas-cli.js b/packages/react-native-codegen/src/cli/combine/combine-schemas-cli.js index ce8334b199f..97ce6e1db3e 100644 --- a/packages/react-native-codegen/src/cli/combine/combine-schemas-cli.js +++ b/packages/react-native-codegen/src/cli/combine/combine-schemas-cli.js @@ -85,6 +85,20 @@ for (const file of schemaFiles) { } } + if (module.type === 'Component') { + const components = module.components || {}; + const isExcludedForPlatform = Object.values(components).some( + component => + component.excludedPlatforms + ?.map(p => p.toLowerCase()) + .includes(platform), + ); + + if (isExcludedForPlatform) { + continue; + } + } + modules[specName] = module; specNameToFile[specName] = file; }