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

[Flight] Expose registerServerReference from the client builds #32534

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Mar 6, 2025

This is used to register Server References that exist in the current environment but also exists in the server it might call into. Such as a remote server.

If the value comes from the remote server in the first place then this is called automatically to ensure that you can pass a reference back to where it came from - even if the serverModuleMap option is used. This was already the case when serverModuleMap wasn't passed. This is how you can pass server references back to the server. However, when we added serverModuleMap that pass was skipped because we were getting real functions instead of proxies.

For functions that wasn't yet passed from the remote server to the current server, we can register them eagerly just like we do for import('/server').registerServerReference(). You can now also do this with import('/client').registerServerReference(). We could make them shared so you only have to do this once but it might not be possible to pass to the remote server and the remote server might not even be the same RSC renderer. Therefore I split them. It's up to the compiler whether it should do that or not. It has to know that any function you might call might be able to receive it. This is currently global to a specific RSC renderer.

This is used to register Server References that exist in the current environment
but also exists in the server it might call into. Such as a remote server.

If the value comes from the remote server in the first place then this is
called automatically to ensure that you can pass a reference back to where
it came from - even if the serverModuleMap option is used .
@react-sizebot
Copy link

Comparing: aac177c...78da3d0

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.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 518.54 kB 518.43 kB = 92.45 kB 92.44 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 589.31 kB 589.24 kB +0.01% 104.91 kB 104.93 kB
facebook-www/ReactDOM-prod.classic.js = 642.76 kB 642.65 kB = 113.01 kB 113.00 kB
facebook-www/ReactDOM-prod.modern.js = 633.08 kB 632.96 kB = 111.44 kB 111.44 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +1.03% 53.61 kB 54.16 kB +0.77% 11.03 kB 11.12 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +1.03% 53.61 kB 54.16 kB +0.77% 11.03 kB 11.12 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +1.02% 54.15 kB 54.71 kB +0.77% 11.12 kB 11.21 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.js +1.01% 54.35 kB 54.90 kB +0.76% 11.15 kB 11.24 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.js +1.01% 54.35 kB 54.90 kB +0.76% 11.15 kB 11.24 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.js +1.00% 54.89 kB 55.44 kB +0.77% 11.24 kB 11.33 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +1.00% 55.14 kB 55.69 kB +0.78% 11.34 kB 11.43 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +1.00% 55.14 kB 55.69 kB +0.78% 11.34 kB 11.43 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +0.99% 55.69 kB 56.24 kB +0.75% 11.43 kB 11.52 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js +0.97% 56.68 kB 57.23 kB +0.79% 11.61 kB 11.70 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js +0.97% 56.68 kB 57.23 kB +0.79% 11.61 kB 11.70 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js +0.96% 57.22 kB 57.77 kB +0.77% 11.70 kB 11.79 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js +0.95% 58.17 kB 58.72 kB +0.77% 11.92 kB 12.01 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js +0.95% 58.17 kB 58.72 kB +0.77% 11.92 kB 12.01 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js +0.95% 58.26 kB 58.81 kB +0.77% 11.95 kB 12.04 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js +0.95% 58.26 kB 58.81 kB +0.77% 11.95 kB 12.04 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js +0.94% 58.72 kB 59.27 kB +0.74% 12.01 kB 12.10 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js +0.94% 58.80 kB 59.35 kB +0.74% 12.03 kB 12.12 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js +0.93% 59.19 kB 59.74 kB +0.76% 11.90 kB 11.99 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js +0.93% 59.19 kB 59.74 kB +0.76% 11.90 kB 11.99 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js +0.92% 59.72 kB 60.27 kB +0.74% 12.00 kB 12.09 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js +0.91% 60.37 kB 60.92 kB +0.74% 12.14 kB 12.23 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js +0.91% 60.37 kB 60.92 kB +0.74% 12.14 kB 12.23 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js +0.90% 60.89 kB 61.44 kB +0.74% 12.23 kB 12.32 kB
oss-stable-semver/react-client/cjs/react-client-flight.production.js +0.73% 57.18 kB 57.59 kB +0.55% 10.65 kB 10.71 kB
oss-stable/react-client/cjs/react-client-flight.production.js +0.73% 57.20 kB 57.62 kB +0.54% 10.68 kB 10.73 kB
oss-experimental/react-client/cjs/react-client-flight.production.js +0.72% 57.66 kB 58.08 kB +0.52% 10.75 kB 10.81 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +0.69% 50.22 kB 50.56 kB +0.63% 10.17 kB 10.23 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +0.69% 50.22 kB 50.56 kB +0.63% 10.17 kB 10.23 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.js +0.69% 50.43 kB 50.78 kB +0.46% 10.29 kB 10.34 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.js +0.69% 50.43 kB 50.78 kB +0.46% 10.29 kB 10.34 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +0.68% 50.76 kB 51.11 kB +0.58% 10.26 kB 10.32 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.js +0.68% 50.98 kB 51.32 kB +0.40% 10.39 kB 10.43 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.production.js +0.66% 52.34 kB 52.69 kB +0.51% 10.68 kB 10.74 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.production.js +0.66% 52.34 kB 52.69 kB +0.51% 10.68 kB 10.74 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js +0.66% 52.77 kB 53.12 kB +0.50% 10.79 kB 10.84 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js +0.66% 52.77 kB 53.12 kB +0.50% 10.79 kB 10.84 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.production.js +0.66% 52.89 kB 53.23 kB +0.41% 10.78 kB 10.83 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js +0.65% 53.32 kB 53.67 kB +0.41% 10.88 kB 10.93 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +0.60% 99.08 kB 99.67 kB +0.44% 18.82 kB 18.90 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +0.60% 99.08 kB 99.67 kB +0.44% 18.82 kB 18.90 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.59% 99.59 kB 100.18 kB +0.46% 18.83 kB 18.92 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.59% 99.59 kB 100.18 kB +0.46% 18.83 kB 18.92 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +0.59% 100.88 kB 101.47 kB +0.42% 19.15 kB 19.23 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +0.59% 100.88 kB 101.47 kB +0.42% 19.15 kB 19.23 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.58% 102.23 kB 102.82 kB +0.44% 19.30 kB 19.39 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.58% 102.23 kB 102.82 kB +0.44% 19.30 kB 19.39 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.57% 103.97 kB 104.57 kB +0.43% 19.62 kB 19.70 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.57% 103.97 kB 104.57 kB +0.43% 19.62 kB 19.70 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.57% 104.06 kB 104.66 kB +0.43% 19.65 kB 19.74 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.57% 104.06 kB 104.66 kB +0.43% 19.65 kB 19.74 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.56% 104.97 kB 105.56 kB +0.44% 19.57 kB 19.65 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.56% 104.97 kB 105.56 kB +0.44% 19.57 kB 19.65 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.56% 106.30 kB 106.89 kB +0.43% 19.82 kB 19.91 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.56% 106.30 kB 106.89 kB +0.43% 19.82 kB 19.91 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +0.54% 108.89 kB 109.48 kB +0.38% 20.82 kB 20.90 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.54% 109.41 kB 110.00 kB +0.41% 20.83 kB 20.92 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +0.53% 110.69 kB 111.29 kB +0.36% 21.19 kB 21.26 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.53% 112.04 kB 112.64 kB +0.39% 21.31 kB 21.39 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.52% 113.79 kB 114.38 kB +0.39% 21.66 kB 21.75 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.52% 113.88 kB 114.47 kB +0.39% 21.70 kB 21.79 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.51% 114.79 kB 115.38 kB +0.40% 21.57 kB 21.66 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.51% 116.12 kB 116.71 kB +0.39% 21.83 kB 21.92 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.46% 95.43 kB 95.86 kB +0.33% 18.09 kB 18.15 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.46% 95.48 kB 95.91 kB +0.33% 18.12 kB 18.18 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +0.45% 95.79 kB 96.22 kB +0.40% 18.04 kB 18.12 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +0.45% 95.84 kB 96.27 kB +0.40% 18.07 kB 18.14 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.js +0.45% 82.03 kB 82.40 kB +0.25% 17.22 kB 17.26 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.js +0.45% 82.03 kB 82.40 kB +0.25% 17.22 kB 17.26 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.js +0.45% 82.76 kB 83.13 kB +0.25% 17.34 kB 17.38 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.45% 97.61 kB 98.05 kB +0.34% 18.48 kB 18.54 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.45% 97.66 kB 98.10 kB +0.34% 18.50 kB 18.56 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.44% 98.17 kB 98.61 kB +0.33% 18.61 kB 18.67 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.44% 98.22 kB 98.66 kB +0.33% 18.64 kB 18.70 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +0.43% 96.78 kB 97.20 kB +0.22% 17.79 kB 17.83 kB
oss-stable/react-client/cjs/react-client-flight.development.js +0.43% 96.81 kB 97.23 kB +0.23% 17.82 kB 17.86 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.41% 105.31 kB 105.74 kB +0.29% 20.12 kB 20.18 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +0.41% 105.66 kB 106.10 kB +0.35% 20.06 kB 20.13 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.40% 107.49 kB 107.93 kB +0.30% 20.51 kB 20.57 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.40% 108.05 kB 108.48 kB +0.33% 20.64 kB 20.71 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +0.39% 106.63 kB 107.05 kB +0.30% 19.85 kB 19.91 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.27% 133.57 kB 133.94 kB +0.15% 31.15 kB 31.20 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.27% 133.60 kB 133.96 kB +0.15% 31.18 kB 31.23 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.25% 145.15 kB 145.52 kB +0.15% 34.06 kB 34.11 kB

Generated by 🚫 dangerJS against c91cd03

@sebmarkbage sebmarkbage merged commit e81fcfe into facebook:main Mar 6, 2025
194 checks passed
unstubbable added a commit to unstubbable/react that referenced this pull request Mar 10, 2025
As a follow-up for facebook#32534 this ensures that
calling `registerServerReference` from the client
builds with a server reference does not overwrite the `bind` method that
was previously defined by the Flight Server.

As was already the case with facebook#32534, the compiler must ensure that the
client-side `registerServerReference` is called after the server-side
`registerServerReference` is called.
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.

None yet

4 participants