Add RSC-based static site generator#10057
Merged
Merged
Conversation
devongovett
commented
Dec 23, 2024
| "targets": { | ||
| "default": { | ||
| "context": "react-server", | ||
| "scopeHoist": false |
Member
Author
There was a problem hiding this comment.
Slightly unfortunate: because we want to skip the JS packager and run the assets during the static packager directly, we have to turn off scope hoisting. It's easy to emulate the dev packager's output with node's vm but hard to handle the structure generated by the scope hoisting transformer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-staticrenames entry bundles to have a.htmlextension, so that the following packager runs.@parcel/packager-react-staticruns 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
.htmlfile, as well as a.rscfile containing the raw RSC stream. This can be used for client-side navigations instead of reloading the whole page. EachPackagedBundlenow has afilesproperty 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.