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] Client and Server Reference Creation into Runtime #27033

Merged
merged 5 commits into from
Jul 7, 2023

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Jul 1, 2023

We already did this for Server References on the Client so this brings us parity with that. This gives us some more flexibility with changing the runtime implementation without having to affect the loaders.

We can also do more in the runtime such as adding .bind() support to Server References.

I also moved the CommonJS Proxy creation into the runtime helper from the register so that it can be handled in one place.

This lets us remove the forks from Next.js since the loaders can be simplified there to just use these helpers.

This PR doesn't change the protocol or shape of the objects. They're still specific to each bundler but ideally we should probably move this to shared helpers that can be used by multiple bundler implementations.

We already did this for Server References on the Client so this brings us
parity with that. This gives us some more flexibility with changing the
runtime implementation without having to affect the loaders.

We can also do more in the runtime such as adding .bind() support to Server
References.
@sebmarkbage sebmarkbage requested a review from gnoff July 1, 2023 04:22
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jul 1, 2023
@react-sizebot
Copy link

react-sizebot commented Jul 1, 2023

Comparing: 2153a29...097d0aa

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 = 164.32 kB 164.32 kB = 51.75 kB 51.75 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 171.73 kB 171.73 kB = 53.97 kB 53.97 kB
facebook-www/ReactDOM-prod.classic.js = 568.20 kB 568.20 kB = 100.14 kB 100.14 kB
facebook-www/ReactDOM-prod.modern.js = 552.00 kB 552.00 kB = 97.29 kB 97.29 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +12.38% 22.27 kB 25.02 kB +9.47% 7.83 kB 8.57 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +12.38% 22.27 kB 25.02 kB +9.47% 7.83 kB 8.57 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +12.38% 22.27 kB 25.02 kB +9.47% 7.83 kB 8.57 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +12.21% 22.57 kB 25.33 kB +9.26% 7.93 kB 8.66 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +12.21% 22.57 kB 25.33 kB +9.26% 7.93 kB 8.66 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +12.21% 22.57 kB 25.33 kB +9.26% 7.93 kB 8.66 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +12.19% 22.47 kB 25.21 kB +9.16% 7.95 kB 8.68 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +12.19% 22.47 kB 25.21 kB +9.16% 7.95 kB 8.68 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +12.19% 22.47 kB 25.21 kB +9.16% 7.95 kB 8.68 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +11.73% 23.53 kB 26.28 kB +9.18% 8.24 kB 8.99 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +11.73% 23.53 kB 26.28 kB +9.18% 8.24 kB 8.99 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +11.73% 23.53 kB 26.28 kB +9.18% 8.24 kB 8.99 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +11.47% 24.06 kB 26.81 kB +8.86% 8.41 kB 9.16 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +11.47% 24.06 kB 26.81 kB +8.86% 8.41 kB 9.16 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +11.47% 24.06 kB 26.81 kB +8.86% 8.41 kB 9.16 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +7.64% 92.28 kB 99.32 kB +7.19% 22.27 kB 23.88 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +7.64% 92.28 kB 99.32 kB +7.19% 22.27 kB 23.88 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +7.64% 92.28 kB 99.32 kB +7.19% 22.27 kB 23.88 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +7.60% 92.69 kB 99.73 kB +7.15% 22.39 kB 23.99 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +7.60% 92.69 kB 99.73 kB +7.15% 22.39 kB 23.99 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +7.60% 92.69 kB 99.73 kB +7.15% 22.39 kB 23.99 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +7.57% 97.59 kB 104.97 kB +7.07% 22.64 kB 24.24 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +7.57% 97.59 kB 104.97 kB +7.07% 22.64 kB 24.24 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +7.57% 97.59 kB 104.97 kB +7.07% 22.64 kB 24.24 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +7.34% 96.00 kB 103.05 kB +6.97% 22.90 kB 24.49 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +7.34% 96.00 kB 103.05 kB +6.97% 22.90 kB 24.49 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +7.34% 96.00 kB 103.05 kB +6.97% 22.90 kB 24.49 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +7.19% 98.05 kB 105.10 kB +6.80% 23.48 kB 25.08 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +7.19% 98.05 kB 105.10 kB +6.80% 23.48 kB 25.08 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +7.19% 98.05 kB 105.10 kB +6.80% 23.48 kB 25.08 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +2.26% 23.35 kB 23.88 kB +2.11% 8.14 kB 8.32 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +2.26% 23.35 kB 23.88 kB +2.11% 8.14 kB 8.32 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +2.26% 23.35 kB 23.88 kB +2.11% 8.14 kB 8.32 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-node-register.js = 4.19 kB 1.37 kB = 1.50 kB 0.74 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-node-register.js = 4.19 kB 1.37 kB = 1.50 kB 0.74 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-node-register.js = 4.19 kB 1.37 kB = 1.50 kB 0.74 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-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +12.38% 22.27 kB 25.02 kB +9.47% 7.83 kB 8.57 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +12.38% 22.27 kB 25.02 kB +9.47% 7.83 kB 8.57 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +12.38% 22.27 kB 25.02 kB +9.47% 7.83 kB 8.57 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +12.21% 22.57 kB 25.33 kB +9.26% 7.93 kB 8.66 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +12.21% 22.57 kB 25.33 kB +9.26% 7.93 kB 8.66 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +12.21% 22.57 kB 25.33 kB +9.26% 7.93 kB 8.66 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +12.19% 22.47 kB 25.21 kB +9.16% 7.95 kB 8.68 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +12.19% 22.47 kB 25.21 kB +9.16% 7.95 kB 8.68 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +12.19% 22.47 kB 25.21 kB +9.16% 7.95 kB 8.68 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +11.73% 23.53 kB 26.28 kB +9.18% 8.24 kB 8.99 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +11.73% 23.53 kB 26.28 kB +9.18% 8.24 kB 8.99 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +11.73% 23.53 kB 26.28 kB +9.18% 8.24 kB 8.99 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +11.47% 24.06 kB 26.81 kB +8.86% 8.41 kB 9.16 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +11.47% 24.06 kB 26.81 kB +8.86% 8.41 kB 9.16 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +11.47% 24.06 kB 26.81 kB +8.86% 8.41 kB 9.16 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +7.64% 92.28 kB 99.32 kB +7.19% 22.27 kB 23.88 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +7.64% 92.28 kB 99.32 kB +7.19% 22.27 kB 23.88 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +7.64% 92.28 kB 99.32 kB +7.19% 22.27 kB 23.88 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +7.60% 92.69 kB 99.73 kB +7.15% 22.39 kB 23.99 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +7.60% 92.69 kB 99.73 kB +7.15% 22.39 kB 23.99 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +7.60% 92.69 kB 99.73 kB +7.15% 22.39 kB 23.99 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +7.57% 97.59 kB 104.97 kB +7.07% 22.64 kB 24.24 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +7.57% 97.59 kB 104.97 kB +7.07% 22.64 kB 24.24 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +7.57% 97.59 kB 104.97 kB +7.07% 22.64 kB 24.24 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +7.34% 96.00 kB 103.05 kB +6.97% 22.90 kB 24.49 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +7.34% 96.00 kB 103.05 kB +6.97% 22.90 kB 24.49 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +7.34% 96.00 kB 103.05 kB +6.97% 22.90 kB 24.49 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +7.19% 98.05 kB 105.10 kB +6.80% 23.48 kB 25.08 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +7.19% 98.05 kB 105.10 kB +6.80% 23.48 kB 25.08 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +7.19% 98.05 kB 105.10 kB +6.80% 23.48 kB 25.08 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +2.26% 23.35 kB 23.88 kB +2.11% 8.14 kB 8.32 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +2.26% 23.35 kB 23.88 kB +2.11% 8.14 kB 8.32 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +2.26% 23.35 kB 23.88 kB +2.11% 8.14 kB 8.32 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.29% 94.74 kB 95.96 kB +1.22% 22.57 kB 22.85 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.29% 94.74 kB 95.96 kB +1.22% 22.57 kB 22.85 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.29% 94.74 kB 95.96 kB +1.22% 22.57 kB 22.85 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-node-register.js = 4.19 kB 1.37 kB = 1.50 kB 0.74 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-node-register.js = 4.19 kB 1.37 kB = 1.50 kB 0.74 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-node-register.js = 4.19 kB 1.37 kB = 1.50 kB 0.74 kB

Generated by 🚫 dangerJS against 097d0aa

@sebmarkbage sebmarkbage force-pushed the flightclientreferences branch from 170bbed to 097d0aa Compare July 1, 2023 05:03
@sebmarkbage sebmarkbage merged commit fdc8c81 into facebook:main Jul 7, 2023
kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Aug 18, 2023
This PR removes our client module reference proxy implementation to directly use the one from the upstream Flight server, as it's added here: facebook/react#27033.

Also updated the server reference creation code a bit to use `defineProperties` - we can't switch to the upstream `registerServerReference` API yet as our Server Actions compiler needs to change a bit to adapt that API since we might have existing `bound` and/or `originalAction` provided.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…27033)

We already did this for Server References on the Client so this brings
us parity with that. This gives us some more flexibility with changing
the runtime implementation without having to affect the loaders.

We can also do more in the runtime such as adding `.bind()` support to
Server References.

I also moved the CommonJS Proxy creation into the runtime helper from
the register so that it can be handled in one place.

This lets us remove the forks from Next.js since the loaders can be
simplified there to just use these helpers.

This PR doesn't change the protocol or shape of the objects. They're
still specific to each bundler but ideally we should probably move this
to shared helpers that can be used by multiple bundler implementations.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
We already did this for Server References on the Client so this brings
us parity with that. This gives us some more flexibility with changing
the runtime implementation without having to affect the loaders.

We can also do more in the runtime such as adding `.bind()` support to
Server References.

I also moved the CommonJS Proxy creation into the runtime helper from
the register so that it can be handled in one place.

This lets us remove the forks from Next.js since the loaders can be
simplified there to just use these helpers.

This PR doesn't change the protocol or shape of the objects. They're
still specific to each bundler but ideally we should probably move this
to shared helpers that can be used by multiple bundler implementations.

DiffTrain build for commit fdc8c81.
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