Skip to content

Fix new codegen API disabling behaviour of the old one #51867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
});
Expand Down Expand Up @@ -778,7 +776,7 @@ exports[`execute test-app-legacy "RCTThirdPartyComponentsProvider.mm" should mat

dispatch_once(&nativeComponentsToken, ^{
thirdPartyComponents = @{

@\\"TestAppDeprecatedComponent\\": NSClassFromString(@\\"RCTTestAppDeprecatedComponentClass\\"), // test-app-legacy
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,23 @@ function generateRCTThirdPartyComponents(

const librariesToCrawl = {} /*:: as {[string]: $FlowFixMe} */;

// 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'), 'utf8'),
Expand All @@ -66,9 +81,6 @@ function generateRCTThirdPartyComponents(
librariesToCrawl[libraryName] = library;

const componentsProvider = config.ios?.componentProvider;
if (!componentsProvider) {
return;
}

delete librariesToCrawl[libraryName];
componentsInLibraries[libraryName] =
Expand All @@ -83,7 +95,7 @@ function generateRCTThirdPartyComponents(
});

// 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;
Expand Down
Loading