diff --git a/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap b/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap index be5220031f1..c91b4b4bea4 100644 --- a/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap +++ b/packages/react-native/scripts/codegen/__tests__/__snapshots__/generate-artifacts-executor-test.js.snap @@ -291,9 +291,7 @@ exports[`execute test-app "RCTThirdPartyComponentsProvider.mm" should match snap dispatch_once(&nativeComponentsToken, ^{ thirdPartyComponents = @{ - @\\"TestAppDeprecatedComponent\\": NSClassFromString(@\\"RCTTestAppDeprecatedComponentClass\\"), // test-app @\\"TestAppComponent\\": NSClassFromString(@\\"RCTTestAppComponent\\"), // test-app - @\\"TestLibraryDeprecatedComponent\\": NSClassFromString(@\\"RCTTestLibraryDeprecatedComponentClass\\"), // test-library @\\"TestLibraryComponent\\": NSClassFromString(@\\"RCTTestLibraryComponent\\"), // test-library }; }); @@ -778,7 +776,7 @@ exports[`execute test-app-legacy "RCTThirdPartyComponentsProvider.mm" should mat dispatch_once(&nativeComponentsToken, ^{ thirdPartyComponents = @{ - + @\\"TestAppDeprecatedComponent\\": NSClassFromString(@\\"RCTTestAppDeprecatedComponentClass\\"), // test-app-legacy }; }); diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js index baadd3eddc9..dc0df1691ed 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js @@ -52,8 +52,23 @@ function generateRCTThirdPartyComponents(libraries, outputDir) { const librariesToCrawl = {}; + // Using new API explicitly or not using any config field to define components. + const componentLibrariesUsingNewApi = []; + const componentLibrariesUsingOldApi = []; + + for (const library of componentLibraries) { + if ( + library.config.ios?.components || + !library.config.ios?.componentProvider + ) { + componentLibrariesUsingNewApi.push(library); + } else { + componentLibrariesUsingOldApi.push(library); + } + } + // Old API - componentLibraries.forEach(library => { + componentLibrariesUsingOldApi.forEach(library => { const {config, libraryPath} = library; const libraryName = JSON.parse( fs.readFileSync(path.join(libraryPath, 'package.json')), @@ -62,9 +77,6 @@ function generateRCTThirdPartyComponents(libraries, outputDir) { librariesToCrawl[libraryName] = library; const componentsProvider = config.ios?.componentProvider; - if (!componentsProvider) { - return; - } delete librariesToCrawl[libraryName]; componentsInLibraries[libraryName] = @@ -79,7 +91,7 @@ function generateRCTThirdPartyComponents(libraries, outputDir) { }); // New API - const iosAnnotations = parseiOSAnnotations(componentLibraries); + const iosAnnotations = parseiOSAnnotations(componentLibrariesUsingNewApi); for (const [libraryName, annotationMap] of Object.entries(iosAnnotations)) { const {library, components} = annotationMap; librariesToCrawl[libraryName] = library;