package.json: Introduce annotations as a way to declare modules/components#49941
Closed
RSNara wants to merge 3 commits into
Closed
package.json: Introduce annotations as a way to declare modules/components#49941RSNara wants to merge 3 commits into
RSNara wants to merge 3 commits into
Conversation
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
c9dc67f to
60f8dfd
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
60f8dfd to
039a6f7
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
039a6f7 to
6670122
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
6670122 to
a837c9c
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
a837c9c to
bbb7154
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
bbb7154 to
3ed8a57
Compare
Summary: This will just make sure that we don't unintentionally break this script. Changelog: [Internal] Differential Revision: D70919549
…9905) Summary: Pull Request resolved: facebook#49905 This diff breaks down generate-artifacts-executor into smaller files. Changelog: [Internal] Differential Revision: D70795042 Reviewed By: alanleedev
…nents Summary: This diff introduces annotations into the ios codegen config! ## Before In the new architecture, people can declare module/component codegen config in [package.json](https://reactnative.dev/docs/the-new-architecture/using-codegen#configuring-codegen) This config contains the following maps: - modulesConformingToProtocol - modulesProvider - componentProvider ``` "codegenConfig": { "name": "HelloWorldSampleModule", "type": "all", "jsSrcsDir": "specs", "android": { "javaPackageName": "com.helloworld" }, "ios": { "modulesConformingToProtocol": { "RCTImageURLLoader": [ "RCTHelloWorldImageURLLoader" ], "RCTURLRequestHandler": [ "RCTHelloWorldURLRequestHandler" ], "RCTImageDataDecoder": [ "RCTHelloWorldImageDataDecoder" ] }, "modulesProvider": { "HelloWorldImageURLLoader": "RCTHelloWorldImageURLLoader", "HelloWorldURLRequestHandler": "RCTHelloWorldURLRequestHandler", "HelloWorldImageDataDecoder": "RCTHelloWorldImageDataDecoder" }, "componentProvider": { "FooComponent": "RCTFooComponentClass" } } ``` ## After This information is a little bit easier to understand if we group it by module/component (into **annotations**): (that's what this diff does!) ``` "codegenConfig": { "name": "HelloWorldSampleModule", "type": "all", "jsSrcsDir": "specs", "android": { "javaPackageName": "com.helloworld" }, "ios": { "modules": { "HelloWorldImageURLLoader": { "conformsToProtocols": ["RCTImageURLLoader"], "className": "RCTHelloWorldImageURLLoader" }, "HelloWorldURLRequestHandler": { "conformsToProtocols": ["RCTURLRequestHandler"], "className": "RCTHelloWorldURLRequestHandler" }, "HelloWorldImageDataDecoder": { "conformsToProtocols": ["RCTImageDataDecoder"], "className": "RCTHelloWorldImageDataDecoder" } }, "components": { "FooComponent": { "className": "RCTFooComponent" } }, } ``` ## Migration The old way is still supported (for now). We will deprecate it soon, and eventually remove it from react native! Changelog: [iOS][Added] - Codegen: Introduce module/component annotations inside package.json Reviewed By: mdvacca Differential Revision: D70822061
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D70822061 |
3ed8a57 to
0f6d5fa
Compare
Contributor
|
This pull request has been merged in 76436d3. |
facebook-github-bot
pushed a commit
that referenced
this pull request
Jun 9, 2025
Summary: Hey, I'm bumping `react-native-screens` to 0.80.0-rc.4 right now & noticed that codegen does not work as expected. It crawls whole library, file by file (when working on a library it also includes nodemodules etc), despite `componentProvider` field being defined in `codegenConfig` in `package.json`. Namely #49941 introduced a regression for libraries that stick to the old codegen config format due to compatibility reasons. Take a look at [this code](https://github.com/facebook/react-native/blob/78caa07ff867255724e4b0ce3557ff5793b6ce1b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js#L60-L103). We first do a pass for "old API", [removing libraries with `componentProvider` in their codegen config from `librariesToCrawl`](https://github.com/facebook/react-native/blob/78caa07ff867255724e4b0ce3557ff5793b6ce1b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js#L66-L75), just to later [add **ALL** libraries](https://github.com/facebook/react-native/blob/78caa07ff867255724e4b0ce3557ff5793b6ce1b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js#L86-L89) that do not support new codegen config format back again to `librariesToCrawl`. This PR improves the filtering condition, to parse codegen annotations only for libraries that have defined any of the fields from the new config format (opted in for new system). I want to emphasise that this is a significant regression, because it ruins experience of library maintenance, vastly increasing pods installation time. ## Changelog: [IOS] [FIXED] - Fix codegen crawling all library code with `componentProvider` defined in config <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: #51867 Test Plan: 1. Setup an application with any third party library, that uses "old" codegen config format, e.g. `react-native-screens@4.11.1` 2. `cd ios && bundle exec pod install` 3. Observe the codegen logs - it crawles the library instead of using provided information. Reviewed By: cortinico Differential Revision: D76126649 Pulled By: cipolleschi fbshipit-source-id: 6f9c9dffcdca7204a78b4b55db10249240146141
react-native-bot
pushed a commit
that referenced
this pull request
Jun 9, 2025
Summary: Hey, I'm bumping `react-native-screens` to 0.80.0-rc.4 right now & noticed that codegen does not work as expected. It crawls whole library, file by file (when working on a library it also includes nodemodules etc), despite `componentProvider` field being defined in `codegenConfig` in `package.json`. Namely #49941 introduced a regression for libraries that stick to the old codegen config format due to compatibility reasons. Take a look at [this code](https://github.com/facebook/react-native/blob/78caa07ff867255724e4b0ce3557ff5793b6ce1b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js#L60-L103). We first do a pass for "old API", [removing libraries with `componentProvider` in their codegen config from `librariesToCrawl`](https://github.com/facebook/react-native/blob/78caa07ff867255724e4b0ce3557ff5793b6ce1b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js#L66-L75), just to later [add **ALL** libraries](https://github.com/facebook/react-native/blob/78caa07ff867255724e4b0ce3557ff5793b6ce1b/packages/react-native/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js#L86-L89) that do not support new codegen config format back again to `librariesToCrawl`. This PR improves the filtering condition, to parse codegen annotations only for libraries that have defined any of the fields from the new config format (opted in for new system). I want to emphasise that this is a significant regression, because it ruins experience of library maintenance, vastly increasing pods installation time. ## Changelog: [IOS] [FIXED] - Fix codegen crawling all library code with `componentProvider` defined in config <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: #51867 Test Plan: 1. Setup an application with any third party library, that uses "old" codegen config format, e.g. `react-native-screens@4.11.1` 2. `cd ios && bundle exec pod install` 3. Observe the codegen logs - it crawles the library instead of using provided information. Reviewed By: cortinico Differential Revision: D76126649 Pulled By: cipolleschi fbshipit-source-id: 6f9c9dffcdca7204a78b4b55db10249240146141
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This diff introduces annotations into the ios codegen config!
Before
In the new architecture, people can declare module/component codegen config in package.json
This config contains the following maps:
After
This information is a little bit easier to understand if we group it by module/component (into annotations):
(that's what this diff does!)
Migration
The old way is still supported (for now). We will deprecate it soon, and eventually remove it from react native!
Changelog: [iOS][Added] - Codegen: Introduce module/component annotations inside package.json
Differential Revision: D70822061