Skip to content

Conversation

@tarunrajput
Copy link
Contributor

@tarunrajput tarunrajput commented Feb 28, 2023

Summary

Extract the buildModuleSchema function (Flow, TypeScript)in the parsers-commons.js function. The two functions are almost identical except for the filter(property =>) at the end of the function, which is different based on the language.

Part of Codegen Issue #34872
Depends on Codegen 74, Codegen 84.

Changelog

[INTERNAL] [CHANGED] - Extract buildModuleSchema from Flow and TypeScript parsers modules to parsers-commons

Test Plan

yarn lint && yarn run flow && yarn test react-native-codegen

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 28, 2023
tryParse,
cxxOnly,
resolveTypeAnnotation,
translateTypeAnnotation,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cipolleschi , Here resolveTypeAnnotation and translateTypeAnnotation are different for both parsers. Could you please confirm whether the two functions should be added as callbacks, or they should be added to their respective parsers? Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to go for the simplest approach. So, for now, it would be easiest to accept them as callback, while we work out the difference and we try to unify them.

If that causes some weird import cycle, we can then understand whether it make sense to move them to the Parsers.

What do you think?

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love that we are removing ~200 LOC here! Thank you so much!

I answered the question in a comment, but it looks good so far!

tryParse,
cxxOnly,
resolveTypeAnnotation,
translateTypeAnnotation,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to go for the simplest approach. So, for now, it would be easiest to accept them as callback, while we work out the difference and we try to unify them.

If that causes some weird import cycle, we can then understand whether it make sense to move them to the Parsers.

What do you think?

@tarunrajput tarunrajput force-pushed the refactor/extract-buildModuleSchema branch from 50de956 to 3e8c4de Compare March 2, 2023 19:04
@analysis-bot
Copy link

analysis-bot commented Mar 2, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,508,872 +0
android hermes armeabi-v7a 7,822,848 +0
android hermes x86 8,986,447 +0
android hermes x86_64 8,842,620 +0
android jsc arm64-v8a 9,135,684 +0
android jsc armeabi-v7a 8,325,234 +0
android jsc x86 9,188,637 +0
android jsc x86_64 9,447,629 +0

Base commit: 947751f
Branch: main

tests(codegen: Add test for buildModuleSchema
@tarunrajput tarunrajput force-pushed the refactor/extract-buildModuleSchema branch from 3e8c4de to 4818733 Compare March 6, 2023 05:21
@tarunrajput tarunrajput marked this pull request as ready for review March 6, 2023 05:36
@tarunrajput tarunrajput requested a review from cipolleschi March 6, 2023 05:36
@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 10, 2023
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in 3cd97e4.

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
> Extract the buildModuleSchema function ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L571), [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L584))in the parsers-commons.js function. The two functions are almost identical except for the filter(property =>) at the end of the function, which is different based on the language.

Part of Codegen Issue facebook#34872
Depends on Codegen 74, Codegen 84.

## Changelog

<!-- 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
-->

[INTERNAL] [CHANGED] - Extract buildModuleSchema from Flow and TypeScript parsers modules to parsers-commons

Pull Request resolved: facebook#36330

Test Plan:
`yarn lint && yarn run flow && yarn test react-native-codegen
`

Reviewed By: christophpurrer

Differential Revision: D43833653

Pulled By: cipolleschi

fbshipit-source-id: 4d67cb5ef746ecd7ace4b91eb30d36e96252e779
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants