-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Codegen] Extract the buildSchema function in the parsers-commons.js #35158
Conversation
Hello @cipolleschi, I don't know what to do to move forward. I extracted the buildSchema function and used the new parser which implements Parser interface. The problem is that ~15 tests do something like this: I changed the buildSchema params so I would have to adapt the tests but parseFile has very few logic: So, for me, parseFile should be moved to FlowParser and TypescriptParser (it seems easier to do it now rather than changing parseFile and all tests to respect new buildSchema interface). So we can do something like: const schema = RealFlowParser.parsefile(`${FIXTURE_DIR}/${fixture}`); instead of: const schema = parseFile(
`${FIXTURE_DIR}/${fixture}`,
DeprecatedFlowParser.buildSchema,
); What do you think of that ? For me the best plan is:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job! 👏
I left a few comments to improve typing, but I love how we are putting code together.
Could you also verify why it is failing in CI? 🙏 |
Thanks the review! 😃 I will address the comments!
@cipolleschi I explained why it's failing here: #35158 (comment) |
e9ed4ac
to
656b486
Compare
Hi @MaeIg, sorry for the long delay. :( The plan sounds good and reasonable. The reason why I haven't suggested that is because I believe Could you create another pr with just that change? In that way, I can import it and see what get broken... Thank you so much for this effort! 🙏 |
The fix for the circular references landed, so you can rebase, fix the conflict and we can push this forward! :D |
It avoid circular dependencies and it is temporary It will be moved again in facebook#35158
It avoid circular dependencies and it is temporary It will be moved again in facebook#35158
It avoid circular dependencies and it is temporary It will be moved again in facebook#35158
It avoid circular dependencies and it is temporary It will be moved again in facebook#35158
It avoid circular dependencies and it is temporary It will be moved again in facebook#35158
…5318) Summary: This PR aims to extract the parseFile function in the typescript and flow parsers. This is to solve the problem described [here](#35158 (comment)) and help with the work done in #34872. ## 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 --> [Internal] [Changed] - Extract the parseFile function in the typescript and flow parsers Pull Request resolved: #35318 Test Plan: yarn flow: <img width="496" alt="image" src="https://user-images.githubusercontent.com/40902940/206518024-83084c3d-ab0d-4a04-810a-d40270add4b0.png"> yarn lint: <img width="495" alt="image" src="https://user-images.githubusercontent.com/40902940/206518076-9e07eafe-db61-4c6e-8aaa-f92f190cf4f3.png"> yarn test: <img width="389" alt="image" src="https://user-images.githubusercontent.com/40902940/206518118-5633b28c-b79b-4421-80f7-de1e03fb8ff2.png"> Reviewed By: cortinico Differential Revision: D41248581 Pulled By: cipolleschi fbshipit-source-id: f5b878a28a7de612fcdd1528f064b44f668503af
Hi @MaeIg! Could you please rebase this PR on top of main? 🙏 Thank you so much. |
6d0ded2
to
d7f8749
Compare
Hello @cipolleschi, Sorry for the delay, I was sick :/ I extracted the buildSchema function but there is a circular dependency. I will try to fix it next week! |
Base commit: efd39ee |
Base commit: 66927ec |
PR build artifact for b5df7e8 is ready. |
PR build artifact for b5df7e8 is ready. |
35fee92
to
1ca77ee
Compare
PR build artifact for 1ca77ee is ready. |
PR build artifact for 1ca77ee is ready. |
Sorry to bother, but it needs another rebase + conflict fixing. :( |
1ca77ee
to
ba1c5d1
Compare
Hello @cipolleschi , it's done! 😄 |
PR build artifact for ba1c5d1 is ready. |
PR build artifact for ba1c5d1 is ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for doing this.
I left a few comment to simplify the code a bit. The main suggestion to implement, imho, is to have the parseModuleFixture
call parseString
rather then invoking the buildSchema directly.
Potentially, we can completely get rid of the index.js
file.
It is to extract buildSchema in a shared file
I took the type from getConfigType params
…rs-common To avoid circular dependencies, functions in utils file should not import functions in parsers-commons. So, this function should go to parsers-commons file
ba1c5d1
to
f575f2b
Compare
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in dc4d73c. |
…d flow parsers (#35928) Summary: This PR aims to extract parseString and parseModuleFixture functions into the typescript and flow parsers. This task was proposed in #35158 and helps #34872. ## 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 parseString and parseModuleFixture functions in typescript and flow parsers Pull Request resolved: #35928 Test Plan: yarn test: <img width="386" alt="image" src="https://user-images.githubusercontent.com/40902940/213889984-f0cadaff-4472-42d6-b55b-4901023aad1e.png"> yarn flow: <img width="166" alt="image" src="https://user-images.githubusercontent.com/40902940/213889974-21ac2483-2731-4cb1-a2b5-195d98619649.png"> yarn lint: <img width="514" alt="image" src="https://user-images.githubusercontent.com/40902940/213889980-090af354-346f-4a9c-90bc-7006899f0819.png"> Reviewed By: jacdebug Differential Revision: D42673866 Pulled By: cipolleschi fbshipit-source-id: f1b5f8a7b3944e7e8223b25c0fb9bf4e8b512aa7
…cebook#35318) Summary: This PR aims to extract the parseFile function in the typescript and flow parsers. This is to solve the problem described [here](facebook#35158 (comment)) and help with the work done in facebook#34872. ## 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 --> [Internal] [Changed] - Extract the parseFile function in the typescript and flow parsers Pull Request resolved: facebook#35318 Test Plan: yarn flow: <img width="496" alt="image" src="https://user-images.githubusercontent.com/40902940/206518024-83084c3d-ab0d-4a04-810a-d40270add4b0.png"> yarn lint: <img width="495" alt="image" src="https://user-images.githubusercontent.com/40902940/206518076-9e07eafe-db61-4c6e-8aaa-f92f190cf4f3.png"> yarn test: <img width="389" alt="image" src="https://user-images.githubusercontent.com/40902940/206518118-5633b28c-b79b-4421-80f7-de1e03fb8ff2.png"> Reviewed By: cortinico Differential Revision: D41248581 Pulled By: cipolleschi fbshipit-source-id: f5b878a28a7de612fcdd1528f064b44f668503af
…35158) Summary: This PR aims to extract the buildSchema function into parsers-commons that is shared between typescript and flow. It is a task of facebook#34872: > Extract the buildSchema function ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/index.js#L66), [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/index.js#L72)) in the parsers-commons.js file to a top level buildSchema function which takes additional parameters to properly parse the content, get the config type and to build the schema, based on the language used. ## 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 --> [Internal] [Changed] - Extract the buildSchema function in the parsers-commons.js Pull Request resolved: facebook#35158 Test Plan: yarn test: <img width="380" alt="image" src="https://user-images.githubusercontent.com/40902940/209584411-40f66047-e25d-43d4-975d-af10cd202f24.png"> yarn flow: <img width="150" alt="image" src="https://user-images.githubusercontent.com/40902940/209584423-4cf2cb5a-a300-40a6-962c-e57934f19ad2.png"> yarn lint: <img width="510" alt="image" src="https://user-images.githubusercontent.com/40902940/209584440-2d2b2658-73d8-47e2-bb8c-64d4633369a2.png"> Reviewed By: cortinico Differential Revision: D42386804 Pulled By: cipolleschi fbshipit-source-id: 2a238f7cec982d8ef3fd57a34dc9f58171e32b53
…d flow parsers (facebook#35928) Summary: This PR aims to extract parseString and parseModuleFixture functions into the typescript and flow parsers. This task was proposed in facebook#35158 and helps facebook#34872. ## 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 parseString and parseModuleFixture functions in typescript and flow parsers Pull Request resolved: facebook#35928 Test Plan: yarn test: <img width="386" alt="image" src="https://user-images.githubusercontent.com/40902940/213889984-f0cadaff-4472-42d6-b55b-4901023aad1e.png"> yarn flow: <img width="166" alt="image" src="https://user-images.githubusercontent.com/40902940/213889974-21ac2483-2731-4cb1-a2b5-195d98619649.png"> yarn lint: <img width="514" alt="image" src="https://user-images.githubusercontent.com/40902940/213889980-090af354-346f-4a9c-90bc-7006899f0819.png"> Reviewed By: jacdebug Differential Revision: D42673866 Pulled By: cipolleschi fbshipit-source-id: f1b5f8a7b3944e7e8223b25c0fb9bf4e8b512aa7
Summary
This PR aims to extract the buildSchema function into parsers-commons that is shared between typescript and flow. It is a task of #34872:
Changelog
[Internal] [Changed] - Extract the buildSchema function in the parsers-commons.js
Test Plan
yarn test:
yarn flow:
yarn lint: