Add server support for React Flight Webpack Plugin #32460
+23
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I know this PR is still a work in progress, but I wanted to share the changes I made to enable webpack-bundled server bundle in my project work and get feedback on whether this approach makes sense.
I've been working on adding server-side support to the React Flight Webpack Plugin and would like to validate my approach before submitting a PR.
Current Implementation
I've modified the ReactFlightWebpackPlugin to handle server-side bundling by:
Generating a
react-server-client-manifest.json
file for the server bundle that maps client component file paths to their server module IDs and chunks. This manifest parallels the client-sidereact-client-manifest.json
but contains server-specific metadata.For server bundles, the plugin tracks module IDs and chunks without creating AsyncDependenciesBlock for client components, as my implementation works with single-chunk server bundles (at least this is the case that I used the updated version of the plugin for).
The plugin combines these manifests during SSR to enable proper client component hydration, mapping between client and server representations of components.
The SSR manifest is then used with:
The implementation worked for my use case, but I'm not sure if it's the correct approach for handling server-side compilation in the webpack plugin.
Questions for Discussion
Is this the correct approach for handling server-side rendering of server and client components?
Manifest Generation:
react-client-manifest.json
andreact-server-client-manifest.json
) the right approach?How did you test this change?