-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Codegen template error in RCTThirdPartyFabricComponentsProvider (#…
…34738) Summary: When `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` generates `RCTThirdPartyFabricComponentsProvider.mm` an edge case happens in the following situation: - The same library exports multiple modules with one component each (i.e. one component per file); - The **first component** is excluded for iOS via the `excludedPlatforms` property in *codegenNativeComponent*. A "loose" comma appears in the generated template, breaking the code. ```c++ Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) { static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = { , // <-- the offending comma {"NativeComponent2", NativeComponent2Cls}, // rnmylibrary }; } ``` At some point, `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` does not properly filter out empty arrays resulting from excluded components. This does not seem to be a problem when the excluded component is not the first being processed, as the comma gets added at the end of the previous line, after the comment with the name of the library. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [iOS] [Fixed] - Fix error in the Codegen template for ThirdPartyFabricComponentsProvider Pull Request resolved: #34738 Test Plan: <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. --> This is the schema that leads to the bug. Notice that the first component was excluded for iOS. ```json { "modules": { "ComponentFile1": { "type": "Component", "components": { "NativeComponent1": { "excludedPlatforms": ["iOS"] "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } }, "ComponentFile2": { "type": "Component", "components": { "NativeComponent2": { "extendsProps": [ { "type": "ReactNativeBuiltInType", "knownTypeName": "ReactNativeCoreViewProps" } ], "events": [], "props": [], "commands": [] } } } } ``` `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` should generate a template without the comma in the wrong position (before NativeComponent2). I also added an additional test case to cover this problem. All the other tests passed. Reviewed By: sammy-SC Differential Revision: D39686573 Pulled By: cipolleschi fbshipit-source-id: 6054464d024218eb0b2e02974aa5cc7c8aebbbc9
- Loading branch information
1 parent
8745a14
commit 2f6b212
Showing
17 changed files
with
571 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.