-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update the default JSX pragma to React instead of @wordpress/element #54494
Conversation
I did a pass on the documentation change on this branch just to have an idea. |
"@wordpress/warning": "file:../warning", | ||
"browserslist": "^4.21.9", | ||
"core-js": "^3.31.0" | ||
"core-js": "^3.31.0", | ||
"react": "^18.2.0" |
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.
I'm not entirely sure that we need this dependency here but I just mirrored the previous @wordpress/element
dependency.
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.
This dependency was added by @gziolo in #17027 and I don't understand the rationale very well. The preset doesn't use element
or react
. The problem was something like when a project (e.g., a block) depends on wp-scripts
, it should install everything wp-scripts
needs automatically, instead of the project's package.json
having to specify additional dependencies explicitly.
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.
I don’t remember the exact reasoning behind it. Maybe there is still value in keeping it but as a peer dependency since it’s React now. Although it doesn’t seem to be necessary anymore for plugins when using wp-scripts build
because it converts imports to react
or wp.element
. It might be different with unit tests though.
1dee6c4
to
6b20c9f
Compare
Size Change: +416 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
6b20c9f
to
8e851ac
Compare
I would love some feedback here. Personally, I feel good about this change and I'm thinking maybe we should land it after 6.4 beta1 that way it doesn't impact the next release but will be ready soon enough for 6.5. |
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.
I've looked at this several times and frankly just don't feel qualified to understand the impact of the change. It seems conceptually like a good move, but I can't think of anything that would break from it. If you want it, I'll give it a 👍, but I would prefer that you lean on review from others on this one.
Thanks for pushing this through.
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.
Looks good, this is a great step forward for Gutenberg.
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.
Great to see, thanks @youknowriad.
Just one minor doc change, LGTM otherwise 🚀
Thanks for the reviews folks. It looks like beta1 for WordPress 6.4 is for next week. I'm going to hold off merging this one until that point to avoid impacting that release for the moment. It will give us time to use this in the plugin phase before 6.5. |
b15f798
to
046c99a
Compare
Flaky tests detected in 046c99a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6336744326
|
Ok, let's give this a try 😬 |
@youknowriad, when do you want to publish the dev note? If I follow correctly, the next step would be to stop using this Babel plugin in gutenberg/packages/babel-preset-default/index.js Lines 78 to 94 in 429e645
Regardless, the changes from this PR will take effect next Wednesday after npm publishing, but they won't get reflected in WordPress core until 6.5 cycle. |
@gziolo Good question, we don't really have a way to publish "posts" about npm changes. I was planning the dev note for 6.5 to avoid messing up with the 6.4 dev notes schedule but it's true that we need to surface this somehow to developers. Maybe we should include a dedicated paragraph in the next Gutenberg release post? |
That would be a good start. There is also https://developer.wordpress.org/news/, and that could be highlighted in the monthly summary post. |
cc @bph for help highlighting this change. |
Build code transformations can introduce dependencies on packages such as `react` and `@babel/runtime`. These need to be declared if the package is to function correctly with yarn's p'n'p or pnpm with hoisting disabled. After WordPress#54494, `@wordpress/icons`, `@wordpress/interactivity`, and `@wordpress/react-i18n` are now lacking peer dependencies on react. `@wordpress/interactivity` also appears to be lacking a dependency or peer dependency on `@babel/runtime`. Fixes WordPress#55171
See #54074 for the reasoning/discussions
This PR implements the change proposed in #54074 to switch the default JSX pragma from @wordpress/element to React. In addition to the current changes, we may want to update our documentation and the files where we currently import
@wordpress/element
and might not need to. I decided to not update these in the same PR to ensure/clarify that with this change, everything continues to work exactly the same without any change to the code base. Also updating documentation and code will quickly result in conflicts unless we merge those PRs quickly, so I'm leaving them separate until the decision is made to merge the current PR.