Add RSC-based static site generator #10057
Merged
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.
This adds plugins for a React Server Components-based static site generator. In this setup, Parcel executes server components during the build and produces static HTML. Client components are hydrated at runtime.
It's implemented in two plugins:
@parcel/namer-static
renames entry bundles to have a.html
extension, so that the following packager runs.@parcel/packager-react-static
runs the JS assets in its bundle at build time, and uses React's static APIs to generate HTML.Core changes are to support packagers returning multiple streams for different versions of the bundle. The react static packager returns both a
.html
file, as well as a.rsc
file containing the raw RSC stream. This can be used for client-side navigations instead of reloading the whole page. EachPackagedBundle
now has afiles
property which lists all of the files produced for that bundle, including source maps, and files produced by compressor plugins as well.Page components receive a list of all of the pages (based on the entry bundles), along with the current page, from the packager as props. This lets them generate navigation links.