-
Notifications
You must be signed in to change notification settings - Fork 24.9k
package.json: Introduce annotations as a way to declare modules/components #49941
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
Conversation
This pull request was exported from Phabricator. Differential Revision: D70822061 |
This pull request was exported from Phabricator. Differential Revision: D70822061 |
c9dc67f
to
60f8dfd
Compare
This pull request was exported from Phabricator. Differential Revision: D70822061 |
60f8dfd
to
039a6f7
Compare
This pull request was exported from Phabricator. Differential Revision: D70822061 |
…nents (facebook#49941) Summary: Pull Request resolved: facebook#49941 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 Differential Revision: D70822061
039a6f7
to
6670122
Compare
This pull request was exported from Phabricator. Differential Revision: D70822061 |
6670122
to
a837c9c
Compare
This pull request was exported from Phabricator. Differential Revision: D70822061 |
…nents (facebook#49941) Summary: Pull Request resolved: facebook#49941 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
a837c9c
to
bbb7154
Compare
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
This pull request was exported from Phabricator. Differential Revision: D70822061 |
3ed8a57
to
0f6d5fa
Compare
This pull request has been merged in 76436d3. |
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
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
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