-
Notifications
You must be signed in to change notification settings - Fork 637
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
Add React JSX runtime to default exceptions for inline requires #1126
Closed
Conversation
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
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
Oct 30, 2023
@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
We also ideally need to do this for |
Chose a different approach for the other change: #1127 |
facebook-github-bot
pushed a commit
that referenced
this pull request
Oct 31, 2023
Summary: There is no benefit to treating Babel helpers with lazy requires. They are always going to be needed, and their initialization is extremely cheap, so it just bloats up the code and adds extra runtime indirection on every access to them. I considered a few alternatives: - We could add them to a default list like #1126. But there's far too many to list individual modules. - We could add wildcard support to `nonInlinedRequires` option. - We could add regex support to `nonInlinedRequires` option. - We could add a new option. I'm not particularly enthusiastic about doing the bigger changes myself. I think hardcoding it here is fine because there's basically no legit reason for wanting these to be lazy. In fact they might even not be lazy anyway depending on where in your compilation pipeline the runtime plugin is injected. But this is nice because it fixes it for all RN users with inline requires. Pull Request resolved: #1127 Test Plan: Ran my app with the change. The app works. The diff looks like I'd expect, for example: <img width="1144" alt="Screenshot 2023-10-31 at 00 40 00" src="https://github.com/facebook/metro/assets/810438/c04f4f5c-0f41-489b-aa50-fac9286f4c1d"> Reviewed By: motiz88 Differential Revision: D50828195 Pulled By: robhogan fbshipit-source-id: b05d26dd26431863deadfae7631913d4dd747a05
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 18, 2024
Summary: Similar to #1126. This call is in every component on every render and it is not beneficial to inline it. On the contrary, you want to reduce the indirection there. Changelog: [Performance] Exclude React Compiler runtime from inline requires <!-- Changelog entries should be prefixed with one of the following scopes: [Breaking, Feature, Fix, Performance, Deprecated, Experimental, Internal] Examples: Changelog: [Fix] Respond with HTTP 404 when a bundle entry point cannot be resolved Changelog: [Internal] --> Changelog: Pull Request resolved: #1390 Test Plan: Before: <img width="846" alt="Screenshot 2024-11-17 at 18 01 25" src="https://github.com/user-attachments/assets/3e04a6b0-dd41-4374-8872-bfc5a1982866"> After: <img width="814" alt="Screenshot 2024-11-17 at 18 08 05" src="https://github.com/user-attachments/assets/fb9cd5dc-2f50-440a-a175-1859e63752a9"> Reviewed By: GijsWeterings Differential Revision: D66075145 Pulled By: robhogan fbshipit-source-id: 11a12fbd04620bdb3e5b9320aca8a02c1f05803f
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
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
JSX runtime calls are all over the place in every components. When using inline requires, it doesn't make sense to go through the method call + array access + property access just to call the JSX factory.
Test plan
Before (with inline requires on):
After (with inline requires on):
I added both
react/jsx-runtime
andreact/jsx-dev-runtime
even though currently RN only uses the former.