-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Fix a few small issues with prerendering in v7 #11833
Conversation
|
@@ -1836,32 +1836,39 @@ async function handlePrerender( | |||
); | |||
} | |||
|
|||
async function prerenderData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was accidentally a locally scoped function inside the parent handlePreRender
function. No changes were made - it just moves out to be a module level function
await prerenderManifest( | ||
build, | ||
clientBuildDirectory, | ||
reactRouterConfig, | ||
viteConfig | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With fog of war we now should prerender the __manifest
as well. This means that statically prerendered sites will load the full manifest on initial load since there's no way to dynamically fetch based on the query params for only outgoing routes - and the enumerations aren't possible to prerender single-request manifest patches.
The only thing I can think of to enable true "fog of war" with prerendering would be to generate a .manifest
file per path (like we do for .data
) and then instead of one request to __manifest
we'd load one request per outgoing path - but that would be be sub-optimal because pages with many links would end many request in parallel.
I think maybe the way to go is when pre-rendering is enabled - disable the "outgoing links" discovery and just let the first link click load the full __manifest
and then all subsequent links clicks would match syncronously.
let mismatchBetweenSsrMatchesAndHydratedMatches = | ||
(initialMatches || []).length !== ssrMatches.length || | ||
!(initialMatches || []).every((m, i) => ssrMatches[i] === m.route.id); | ||
if (mismatchBetweenSsrMatchesAndHydratedMatches) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detect via matches and not URL to avoid false positives from trailing slashes - more prevalent in a prerendered world
if (url.pathname === "/") { | ||
url.pathname = "_root.data"; | ||
} else { | ||
url.pathname = `${url.pathname.replace(/\/$/, "")}.data`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing slashes when generating single fetch data calls
866ba38
to
3278f3c
Compare
if (res.status === 404) { | ||
throw new ErrorResponseImpl(404, "Not Found", true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bubble a proper 404 to our UI if we're in a prerendered app and there is no static file on the server
Note: Ignore the first 2 commits as they were made in Remix and have since been brought over to dev and upmerged into here (see remix-run/remix#9695 and remix-run/remix#9792)
This PR adds:
__manifest
to handle lazy route discovery in a prerendered appErrorResponse
404 bubbling on single fetch.data
requests to a non-existent prerendered.data
file on the CDN