Skip to content
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

Duplicate of #23385 for debugging purposes #23388

Closed
wants to merge 8 commits into from

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Mar 1, 2022

Duplicate of #23385 for debugging purposes

Trying to fix the DevTools Webpack config

We want these APIs ideally to be imported separately from things you
might use in arbitrary components (like flushSync). Those other methods
are "isomorphic" to how the ReactDOM tree is rendered. Similar to hooks.

E.g. importing flushSync into a component that only uses it on the client
should ideally not also pull in the entry client implementation on the
server.

This also creates a nicer parity with /server where the roots are in a
separate entry point.

Unfortunately, I can't quite do this yet because we have some legacy APIs
that we plan on removing (like findDOMNode) and we also haven't implemented
flushSync using a flag like startTransition does yet.

Another problem is that we currently encourage these APIs to be aliased by
/profiling (or unstable_testing). In the future you don't have to alias
them because you can just change your roots to just import those APIs and
they'll still work with the isomorphic forms. Although we might also just
use export conditions for them.

For that all to work, I went with a different strategy for now where the
real API is in / but it comes with a warning if you use it. If you instead
import /client it disables the warning in a wrapper. That means that if you
alias / then import /client that will inturn import the alias and it'll
just work.

In a future breaking changes (likely when we switch to ESM) we can just
remove createRoot/hydrateRoot from / and move away from the aliasing
strategy.
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 1, 2022
@sizebot
Copy link

sizebot commented Mar 1, 2022

Comparing: 086fa8e...db8d306

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.02% 131.44 kB 131.46 kB +0.05% 42.04 kB 42.06 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.02% 136.09 kB 136.12 kB +0.05% 43.39 kB 43.41 kB
facebook-www/ReactDOM-prod.classic.js = 435.10 kB 435.13 kB +0.03% 79.59 kB 79.61 kB
facebook-www/ReactDOM-prod.modern.js = 421.60 kB 421.63 kB +0.03% 77.57 kB 77.59 kB
facebook-www/ReactDOMForked-prod.classic.js = 435.10 kB 435.13 kB +0.03% 79.59 kB 79.61 kB
oss-experimental/react-dom/client.js +∞% 0.00 kB 0.62 kB +∞% 0.00 kB 0.29 kB
oss-stable-semver/react-dom/client.js +∞% 0.00 kB 0.62 kB +∞% 0.00 kB 0.29 kB
oss-stable/react-dom/client.js +∞% 0.00 kB 0.62 kB +∞% 0.00 kB 0.29 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-dom/client.js +∞% 0.00 kB 0.62 kB +∞% 0.00 kB 0.29 kB
oss-stable-semver/react-dom/client.js +∞% 0.00 kB 0.62 kB +∞% 0.00 kB 0.29 kB
oss-stable/react-dom/client.js +∞% 0.00 kB 0.62 kB +∞% 0.00 kB 0.29 kB

Generated by 🚫 dangerJS against db8d306

@acdlite acdlite force-pushed the debug-devtools-webpack branch 3 times, most recently from 90200be to 9e99692 Compare March 1, 2022 04:25
I think the order matters here. The first one takes precedence.
@acdlite acdlite force-pushed the debug-devtools-webpack branch from 9e99692 to 4149b68 Compare March 1, 2022 04:41
The wrapper module should import "react-dom" instead of "./" so that if
"react-dom" is aliased, it imports the alised one.
@acdlite acdlite force-pushed the debug-devtools-webpack branch from 4149b68 to db8d306 Compare March 1, 2022 05:02
@acdlite acdlite closed this Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants