React vendor script: avoid warning on createRoot#76825
Conversation
| global: 'ReactDOM', | ||
| contents: [ | ||
| 'export * from "react-dom";', | ||
| 'export { createRoot, hydrateRoot } from "react-dom/client";', |
There was a problem hiding this comment.
The react-dom/client re-exports will reliably override the * re-export from react-dom, we don't need to do any special tricks here.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +425 B (+0.01%) Total Size: 7.69 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in a2fd171. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23593326378
|
Mamaduka
left a comment
There was a problem hiding this comment.
Can confirm that this fixes the warning ✅
|
I'm having a hard time following the benefit we're hoping to get from this. If it's not an issue in |
f92a2f1 to
a2fd171
Compare
So, I'll check what React 19 does, I suspect it's very different than React 18.3.1. |
With React 19, as we have it in #61521, the situation is much worse and this PR will solve a much bigger problem.
The entire reconciliation engine is in Because we externalize only If we want to keep one |
So is there follow-up work to be done there? Like, we'd update Should we be going about this another way instead and adding |
Yes, as a follow-up, we would externalize the
That's another option, creating a new Until React 18, there was a clear standard how a React/ReactDOM UMD script should look like, and what are the But since React 19, there are no UMD scripts, just ES modules and a growing number of export paths defined in We could merge the tiny packages into the big ones. The It's completely up to us how we define |
a2fd171 to
d0d2c6e
Compare
|
Yeah, I don't really have strong feelings, or not enough to be a blocker. I think this approach is fine. Especially if now ReactDOM globals aren't really a "standard" thing that we're deviating from. But it does sound like with this implementation we'll have future changes that look like |
While working on #76811 and looking at @youknowriad's old Core patch in https://core.trac.wordpress.org/changeset/58775 I realized that our
react-dombundled vendor script has one little bug. It reexportscreateRootdirectly fromreact-dom, not from the recommendedreact-dom/clientpackage, and that triggers a warning:The function is there, it works, but triggers a warning.
We usually don't see this because we typically use
createRootimported from@wordpress/element, where the reexport is done correctly, fromreact-dom/client.This patch fixes that by providing explicit content string of the
react-domentrypoint.How to test:
Build Gutenberg locally, load Gutenberg in browser, and then call this in console:
Before this PR you'll see a warning, after this PR the warning is no longer there.