From 8d3c9ec3a161224582fd8e342cc4df4b3c77ec32 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 6 Dec 2024 05:05:48 -0800 Subject: [PATCH] Exclude mapping generation of core component (#48145) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48145 While writing the docs for 0.77, I found an edge case in the generation of the RCTThirdPartyComponentProvider: * If the app has the `codegenConfig` field set in the `package.json` * And it does not have the `ios.componentProvider` field is not provided Codegen was generating the mapping for the react-native core components. That's not expected as, in that case, it should only generate components that are declared in the app or in libraries. This change fixes this edge case. ## Changelog: [Internal] - Exclude mapping generation of core component Reviewed By: blakef Differential Revision: D66875080 fbshipit-source-id: 65fe10381729ec7808efec70feacf2a55f0056e9 --- .../scripts/codegen/generate-artifacts-executor.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js index c1fc5aeaf99..440b25c02a7 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js @@ -778,6 +778,11 @@ function findFilesWithExtension(filePath, extension) { // Given a filepath, read the file and look for a string that starts with 'Class ' // and ends with 'Cls(void)'. Return the string between the two. function findRCTComponentViewProtocolClass(filepath) { + // Exclude files provided by react-native + if (filepath.includes(`${path.sep}react-native${path.sep}`)) { + return null; + } + const fileContent = fs.readFileSync(filepath, 'utf8'); const regex = /Class (.*)Cls\(/; const match = fileContent.match(regex);