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

Implement react-server-dom-parcel #31725

Merged
merged 25 commits into from
Dec 12, 2024
Merged

Conversation

devongovett
Copy link
Contributor

This adds a new react-server-dom-parcel-package, which is an RSC integration for the Parcel bundler. It is mostly copied from the existing webpack/turbopack integrations, with some changes to utilize Parcel runtime APIs for loading and executing bundles/modules.

See parcel-bundler/parcel#10043 for the Parcel side of this, which includes the plugin needed to generate client and server references. https://github.com/parcel-bundler/rsc-examples also includes examples of various ways to use RSCs with Parcel.

Differences from other integrations:

  • Client and server modules are all part of the same graph, and we use Parcel's environments to distinguish them. The server is the Parcel build entry point, and it imports and renders server components in route handlers. When a "use client" directive is seen, the environment changes and Parcel creates a new client bundle for the page, combining all client modules together. CSS from both client and server components are also combined automatically.
  • There is no separate manifest file that needs to be passed around by the user. A Runtime plugin injects client and server references as needed into the relevant bundles, and registers server action ids using react-server-dom-parcel automatically.
  • A special <Resources> component is also generated by Parcel to render the <script> and <link rel="stylesheet"> elements needed for a page, using the relevant info from the bundle graph.

Note: I've already published a 0.0.x version of this package to npm for testing purposes but happy to add whoever needs access to it as well.

Questions

  • How to test this in the React repo. I'll have integration tests in Parcel, but setting up all the different mocks and environments to simulate that here seems challenging. I could try to copy how Webpack/Turbopack do it but it's a bit different.
  • Where to put TypeScript types. Right now I have some ambient types in my example repo but it would be nice for users not to copy and paste these. Can I include them in the package or do they need to maintained separately in definitelytyped? I would really prefer not to have to maintain code in three different repos ideally.

Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 3:53am

@react-sizebot
Copy link

react-sizebot commented Dec 10, 2024

Comparing: a496498...03d8eba

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.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 510.76 kB 510.76 kB = 91.41 kB 91.41 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 = 515.69 kB 515.69 kB = 92.12 kB 92.12 kB
facebook-www/ReactDOM-prod.classic.js = 595.61 kB 595.61 kB = 105.12 kB 105.12 kB
facebook-www/ReactDOM-prod.modern.js = 585.88 kB 585.88 kB = 103.55 kB 103.55 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 95.28 kB +∞% 0.00 kB 17.84 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 50.48 kB +∞% 0.00 kB 10.21 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 100.44 kB +∞% 0.00 kB 19.02 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.79 kB +∞% 0.00 kB 11.17 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 98.64 kB +∞% 0.00 kB 18.69 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 53.26 kB +∞% 0.00 kB 10.86 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 143.20 kB +∞% 0.00 kB 26.53 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 89.96 kB +∞% 0.00 kB 18.55 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 146.35 kB +∞% 0.00 kB 27.00 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 90.41 kB +∞% 0.00 kB 18.67 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 147.93 kB +∞% 0.00 kB 27.47 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 93.41 kB +∞% 0.00 kB 19.30 kB
oss-experimental/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-experimental/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-experimental/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 86.97 kB +∞% 0.00 kB 16.29 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 49.97 kB +∞% 0.00 kB 10.12 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 91.84 kB +∞% 0.00 kB 17.37 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.28 kB +∞% 0.00 kB 11.09 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 90.04 kB +∞% 0.00 kB 17.02 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 52.75 kB +∞% 0.00 kB 10.78 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 128.81 kB +∞% 0.00 kB 24.22 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 84.25 kB +∞% 0.00 kB 17.74 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 130.26 kB +∞% 0.00 kB 24.48 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 84.61 kB +∞% 0.00 kB 17.83 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 132.71 kB +∞% 0.00 kB 24.89 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 87.72 kB +∞% 0.00 kB 18.37 kB
oss-stable-rc/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-stable-rc/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-stable-rc/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 86.97 kB +∞% 0.00 kB 16.29 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 49.97 kB +∞% 0.00 kB 10.12 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 91.84 kB +∞% 0.00 kB 17.37 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.28 kB +∞% 0.00 kB 11.09 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 90.04 kB +∞% 0.00 kB 17.02 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 52.75 kB +∞% 0.00 kB 10.78 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 128.81 kB +∞% 0.00 kB 24.22 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 84.25 kB +∞% 0.00 kB 17.74 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 130.26 kB +∞% 0.00 kB 24.48 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 84.61 kB +∞% 0.00 kB 17.83 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 132.71 kB +∞% 0.00 kB 24.89 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 87.72 kB +∞% 0.00 kB 18.37 kB
oss-stable-semver/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-stable-semver/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-stable-semver/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 86.97 kB +∞% 0.00 kB 16.29 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 49.97 kB +∞% 0.00 kB 10.12 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 91.84 kB +∞% 0.00 kB 17.37 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.28 kB +∞% 0.00 kB 11.09 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 90.04 kB +∞% 0.00 kB 17.02 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 52.75 kB +∞% 0.00 kB 10.78 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 128.81 kB +∞% 0.00 kB 24.22 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 84.25 kB +∞% 0.00 kB 17.74 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 130.26 kB +∞% 0.00 kB 24.48 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 84.61 kB +∞% 0.00 kB 17.83 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 132.71 kB +∞% 0.00 kB 24.89 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 87.72 kB +∞% 0.00 kB 18.37 kB
oss-stable/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-stable/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-stable/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 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-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 95.28 kB +∞% 0.00 kB 17.84 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 50.48 kB +∞% 0.00 kB 10.21 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 100.44 kB +∞% 0.00 kB 19.02 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.79 kB +∞% 0.00 kB 11.17 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 98.64 kB +∞% 0.00 kB 18.69 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 53.26 kB +∞% 0.00 kB 10.86 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 143.20 kB +∞% 0.00 kB 26.53 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 89.96 kB +∞% 0.00 kB 18.55 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 146.35 kB +∞% 0.00 kB 27.00 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 90.41 kB +∞% 0.00 kB 18.67 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 147.93 kB +∞% 0.00 kB 27.47 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 93.41 kB +∞% 0.00 kB 19.30 kB
oss-experimental/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-experimental/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-experimental/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-experimental/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 86.97 kB +∞% 0.00 kB 16.29 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 49.97 kB +∞% 0.00 kB 10.12 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 91.84 kB +∞% 0.00 kB 17.37 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.28 kB +∞% 0.00 kB 11.09 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 90.04 kB +∞% 0.00 kB 17.02 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 52.75 kB +∞% 0.00 kB 10.78 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 128.81 kB +∞% 0.00 kB 24.22 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 84.25 kB +∞% 0.00 kB 17.74 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 130.26 kB +∞% 0.00 kB 24.48 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 84.61 kB +∞% 0.00 kB 17.83 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 132.71 kB +∞% 0.00 kB 24.89 kB
oss-stable-rc/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 87.72 kB +∞% 0.00 kB 18.37 kB
oss-stable-rc/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-stable-rc/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-stable-rc/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-stable-rc/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 86.97 kB +∞% 0.00 kB 16.29 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 49.97 kB +∞% 0.00 kB 10.12 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 91.84 kB +∞% 0.00 kB 17.37 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.28 kB +∞% 0.00 kB 11.09 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 90.04 kB +∞% 0.00 kB 17.02 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 52.75 kB +∞% 0.00 kB 10.78 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 128.81 kB +∞% 0.00 kB 24.22 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 84.25 kB +∞% 0.00 kB 17.74 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 130.26 kB +∞% 0.00 kB 24.48 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 84.61 kB +∞% 0.00 kB 17.83 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 132.71 kB +∞% 0.00 kB 24.89 kB
oss-stable-semver/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 87.72 kB +∞% 0.00 kB 18.37 kB
oss-stable-semver/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-stable-semver/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-stable-semver/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-stable-semver/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js +∞% 0.00 kB 86.97 kB +∞% 0.00 kB 16.29 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.production.js +∞% 0.00 kB 49.97 kB +∞% 0.00 kB 10.12 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +∞% 0.00 kB 91.84 kB +∞% 0.00 kB 17.37 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.production.js +∞% 0.00 kB 54.28 kB +∞% 0.00 kB 11.09 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +∞% 0.00 kB 90.04 kB +∞% 0.00 kB 17.02 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.production.js +∞% 0.00 kB 52.75 kB +∞% 0.00 kB 10.78 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.development.js +∞% 0.00 kB 128.81 kB +∞% 0.00 kB 24.22 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.browser.production.js +∞% 0.00 kB 84.25 kB +∞% 0.00 kB 17.74 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.development.js +∞% 0.00 kB 130.26 kB +∞% 0.00 kB 24.48 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.edge.production.js +∞% 0.00 kB 84.61 kB +∞% 0.00 kB 17.83 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +∞% 0.00 kB 132.71 kB +∞% 0.00 kB 24.89 kB
oss-stable/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.production.js +∞% 0.00 kB 87.72 kB +∞% 0.00 kB 18.37 kB
oss-stable/react-server-dom-parcel/client.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/client.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/client.js +∞% 0.00 kB 0.06 kB +∞% 0.00 kB 0.08 kB
oss-stable/react-server-dom-parcel/client.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/index.js +∞% 0.00 kB 0.28 kB +∞% 0.00 kB 0.22 kB
oss-stable/react-server-dom-parcel/server.browser.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/server.edge.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/server.js +∞% 0.00 kB 0.19 kB +∞% 0.00 kB 0.16 kB
oss-stable/react-server-dom-parcel/server.node.js +∞% 0.00 kB 0.25 kB +∞% 0.00 kB 0.16 kB

Generated by 🚫 dangerJS against 2bf70e9

export function preloadModule<T>(
metadata: ClientReference<T>,
): null | Thenable<any> {
return Promise.all(metadata.bundles.map(url => parcelRequire.load(url)));
Copy link
Collaborator

@sebmarkbage sebmarkbage Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that this will ever be empty? Such as if it's a module that's part of the core runtime or something? If so, it could be good to return null in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment I don't think it's possible, but could be in the future I think, e.g. if the bundler knows that everything needed will already be available on the page. I'll add that condition.

@sebmarkbage
Copy link
Collaborator

How to test this in the React repo.

It would be good to have something like the /fixtures/flight-esm example. It can depend on the npm version of Parcel that you've published and just show a minimal set up. Think the smallest sample app you might publish as part of docs or something anyway. Just to have something we can run to test that it works when we're refactoring or add features / instrumentation.

Where to put TypeScript types.

You can put them for this package on DefinitelyTyped potentially. However, you might also want to publish a wrapper library that either depends on react-server-dom-parcel or vendors it. Where this is more the implementation detail. Then that wrapper library can be built with TypeScript and publish its own types in front and that's the one people actually interact with.

@sebmarkbage
Copy link
Collaborator

Copy/pasting https://github.com/parcel-bundler/rsc-examples/tree/main into the fixtures repo might be enough?

nonce: ?string,
metadata: ClientReferenceMetadata,
) {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By not implementing this, the thing you lose out on is the ability to emit early loading of the modules during SSR. So it would have to wait until hydration to kick off loading the bundles that will later be needed.

It's a little convoluted the way that's wired up in the other packages to only do that for SSR and not in the browser.

But the key is that you just need some way to provide the absolute URL that the browser would load.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <Resources> component we have inserts scripts and stylesheets needed by the page based on dependencies in the module graph, so I thought this wasn't needed at first. But thinking about it more, in theory there could be bundles that are discovered conditionally during render (e.g. if a component does a dynamic import()). I can add something similar to what the other packages are doing.

Looks like this only supports preloading JS and not CSS though? So in the case where resources were discovered during render, we'd preload the JS but the CSS would only be discovered during hydration. Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think we need to find a way to render a <link> element in the tree during render for dynamic imports. Otherwise there will be FOUC before hydration. This can be done manually by rendering <Resources> inside each dynamically imported component. I guess that would solve the issue for JS too. Would be cool if this could happen automatically though....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebmarkbage I think I could potentially generate a proxy module when you use dynamic import() inside a server component (either for another server component or a client component), and emit wrappers that would insert the necessary <link> elements.

I think this can't be done in prepareDestinationForModule since that only knows about client components, and not about css needed for server components (when there are no client components). And it should suspend on the css to avoid FOUC (I think preinit does not?).

The hard part is knowing what is a valid component that should be wrapped by the proxy. We wouldn't want to unintentionally change the return type of a non-component function by wrapping it with extra JSX elements.

Should there be a way of annotating server component exports with their resources so that stylesheets can be inserted automatically? Manually adding <Resources> in every component that you dynamic import() might be hard to remember.

id: metadata[ID],
name: metadata[NAME],
bundles: metadata[BUNDLES],
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this isn't just an identity function returning the same type of object?

* @flow
*/

export {prerenderToNodeStream} from './src/server/react-flight-dom-server.node';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have changed names now but nbd. I'll take a pass over to make sure all changes are caught up once we land.

@sebmarkbage
Copy link
Collaborator

sebmarkbage commented Dec 12, 2024

I pushed a fixture that just copies the SSR example from https://github.com/parcel-bundler/rsc-examples/tree/main/examples/server

One thing I couldn't figure out is how to run it in development mode and the watch mode. Something seems maybe broken there. We'd need something like that to test the dev mode features.

EDIT: Got it working but I think there's a way to mess up the parcel-cache so I sometimes get into a broken state.

These get overridden anyway.
This runs watch and NODE_ENV=development.
@sebmarkbage
Copy link
Collaborator

I'm going to merge since this is in a good enough to iterate on. Fixture seems to be working.

@sebmarkbage sebmarkbage merged commit ca58742 into facebook:main Dec 12, 2024
187 checks passed
@sebmarkbage
Copy link
Collaborator

One thing that could be better is the source mapping. RSC wires up source mapping using findSourceMapURL on the client side. See: #30758

It's supposed to return the URL of the source map for that server file from the client. This could maybe be left to a user space option but it would be even better if it was built-in somehow.

@devongovett
Copy link
Contributor Author

However, you might also want to publish a wrapper library that either depends on react-server-dom-parcel or vendors it. Where this is more the implementation detail.

I was wondering if I should do that. Is the plan for these bundler integrations published by React to follow semver or always be internal with the intent that they should be wrapped by something higher level?

One thing that could be better is the source mapping. RSC wires up source mapping using findSourceMapURL on the client side.

Yeah I meant to look into this. I think we can add something to Parcel's dev server, which is also used for HMR.

sebmarkbage added a commit that referenced this pull request Dec 12, 2024
Follow up to #31725.

I diffed against the Turbopack one to find any unexpected discrepancies.
Some parts are forked enough that it's hard to diff but I think I got
most of it.
sebmarkbage pushed a commit that referenced this pull request Dec 31, 2024
Followup to #31725

This implements `prepareDestinationForModule` in the Parcel Flight
client. On the Parcel side, the `<Resources>` component now only inserts
`<link>` elements for stylesheets (along with a bootstrap script when
needed), and React is responsible for inserting scripts. This ensures
that components that are conditionally dynamic imported during render
are also preloaded.

CSS must be added to the RSC tree using `<Resources>` to avoid FOUC.
This must be manually rendered in both the top-level page, and in any
component that is dynamic imported. It would be nice if there was a way
for React to automatically insert CSS as well, but unfortunately
`prepareDestinationForModule` only knows about client components and not
CSS for server components. Perhaps there could be a way we could
annotate components at code splitting boundaries with the resources they
need? More thoughts in this thread:
#31725 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants