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

feat: New Serialization Paradigm #1824

Merged
merged 30 commits into from
Jun 28, 2024
Merged

feat: New Serialization Paradigm #1824

merged 30 commits into from
Jun 28, 2024

Conversation

tannerlinsley
Copy link
Collaborator

@tannerlinsley tannerlinsley commented Jun 24, 2024

  • This reworks the entire serialization model including deferred streaming of data.
  • Instead of using stream injection, it uses suspense for promises and recursive suspense for streams.
  • defer(promise) is no longer needed, since we are walking the loader return and extracting promises and streams now.
  • Await is still required in React <19 to consume deferred promises, but in 19, use will work just fine.
  • The SSR and start examples now use the new , , and tags, which are also required for non React 19 full document hydration
  • It begins (but doesn't fully flesh out), a universal server entry via createStartHandler. More work is needed for non-start SSR envs to use it, which is where createRequestHandler needs some more polish.
  • Provides experimental support for RSCs. This does not include using client components yet (which will require a bit more work around RSC manifests for the client. @devagrawal09?)
  • RSC requires that you override the react and react-dom version at the mono repo level. There are temp- entries there for what I know works
  • Rendering RSCs requires the new renderRsc function, exported from @tanstack/start, which uses the new react-server-dom/client to isomorphically create React elements from either Readable's on the server or ReadableStreams/Fetches on the client. One of the reasons for this renderRsc() step is so that RSCs remain primitive streams until they can be handled by the router for SSR and caching, after which they are released back to the user via useLoaderData for consumption. Diving deeper, the primary reason for this is so that we can gain access to the original binary chunks of RSC syntax that are being streamed across the wire. Without access to those chunks, we cannot serialize and recreate the RSC across any serialization boundary.
  • Some components and utilities have been further extracted into their own files to avoid circular deps, types and ultimately, mixing of client and server imports during RSC. There will be a lot more work to do here when we enable client components, as we will need to make sure server-capable router imports do not bring in useState, etc. I still have strong feelings that these imports shouldn't be invariants during bundling and should only warn at runtime... but I digress.
  • The component got serious upgrades along with an undocumented feature of using the .tsr-once class to ensure than an element is completely removed before hydration is attempted.

Copy link

nx-cloud bot commented Jun 24, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3b35e77. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

@tannerlinsley
Copy link
Collaborator Author

I'm not completely sure how to get things passing without forcing the entire monorepo into React 19...

@SeanCassiere

This comment was marked as resolved.

@SeanCassiere

This comment was marked as resolved.

@tannerlinsley tannerlinsley changed the title feat: Better Serialization, RSC Proof of Concept feat: New Serialization Paradigm Jun 28, 2024
@tannerlinsley tannerlinsley merged commit fd692cf into main Jun 28, 2024
9 checks passed
@tannerlinsley tannerlinsley deleted the rsc branch June 28, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants