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(nuxt): server-only pages #24954
Conversation
Run & review this pull request in StackBlitz Codeflow. |
β¦le the transition component
β¦feat/server-page
β¦feat/server-page
definePageMeta
macroCo-authored-by: Daniel Roe <daniel@roe.dev>
@@ -160,6 +162,7 @@ export default defineComponent({ | |||
// TODO: Validate response | |||
// $fetch handles the app.baseURL in dev | |||
const r = await eventFetch(withQuery(((import.meta.dev && import.meta.client) || props.source) ? url : joinURL(config.app.baseURL ?? '', url), { | |||
url: route.fullPath, |
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.
I think this will make it much harder to cache server islands as the hash we create will vary by path.
Could we instead pass this as part of the context via createIslandPage
instead (and maybe use route.path
to skip query/hash)?
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.
I think we should not skip query π€, userss tend to relly on it within pages composables. Maybe can we pass an object like
{
path: string,
query?: Record<string, string>
}
?
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.
The issue is (for example) that we will make a separate request for every query variation, which wouldn't be compatible with static sites and allow cache-busting by passing arbitrary query params or hashes ... (We should definitely not pass hash.) We could document this as a limitation of server pages... Or at a minimum, skip passing the full route if the route matches prerender routeRule?
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.
I see, let's start by passing only the path in the context then π€. and iterate on it, i'm not sure what kind of side effect we can have if using fullPath with ssg
β¦feat/server-page
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 looks great to me.
I do think we probably could respect the route query as long as it's not a prerendered page. (We can use isPrerendered
to tell us.).
And I think we should drop the support for defining server-only pages within definePageMeta
, which means that it's impossible to tree-shake this code out of the bundle, if even one page has any metadata at all.
β¦ `pages:extend`
There seems to be an issue with this if you try to directly access the server-only page in dev:
It works fine if you open home first and then go to server-only page via link π |
π Linked issue
β Type of change
#19772
π Description
Hi π this PR allows users to define pages as server page with
definePageMeta()
and the.server.vue
suffix in the filename.inFor the client only implementation, see #25037definePageMeta
this PR took #25037 as reference for the field name :mode
. For now it only accept undefined or'server'
.π Checklist