feat(qwik-router): exclude prerendered routes from the server route plan#8742
Open
briancarbone wants to merge 1 commit into
Open
feat(qwik-router): exclude prerendered routes from the server route plan#8742briancarbone wants to merge 1 commit into
briancarbone wants to merge 1 commit into
Conversation
Add an opt-in `serverExcludeRoutes` option (glob patterns, same syntax as the SSG adapter's `ssg.include`). Matching static page routes are omitted from the runtime server route plan, so their components tree-shake out of the deployed server bundle. This keeps size-capped edge runtimes (e.g. Cloudflare Workers) from growing with prerendered page count. SSG still prerenders the routes and the client/SPA build is unaffected. The SSG build entry imports a new `@qwik-router-config?ssg` variant that always carries the full route plan; dev and the client build keep every route as well. Exclusion applies to the production server build only. Restricted to static (non-dynamic) routes with no server action$ or per-request SSR fallback; the user certifies a listed route is fully static.
🦋 Changeset detectedLatest commit: ab7e7a9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Author
|
This would be better implemented by detecting routes with non-GET server entry points; then you could have just |
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.
What is it?
Description
Add an opt-in
serverExcludeRoutesoption (glob patterns, same syntax as the SSG adapter'sssg.include). Matching static page routes are omitted from the runtime server route plan, so their components tree-shake out of the deployed server bundle. This keeps size-capped edge runtimes (e.g. Cloudflare Workers) from growing with prerendered page count.SSG still prerenders the routes and the client/SPA build is unaffected. The SSG build entry imports a new
@qwik-router-config?ssgvariant that always carries the full route plan; dev and the client build keep every route as well. Exclusion applies to the production server build only.Restricted to static (non-dynamic) routes with no server
action$or per-request SSR fallback; the user certifies a listed route is fully static.How it works
createRouteTester(the same matcher SSG uses), so the glob syntax is identical tossg.include.createRoutes, a matched static route's loader is skipped, so its trie node prunes and the route's chunk tree-shakesout.
routeIdMapmembership stays the single source of truth (the_Rloader-hash emission now mirrors it).@qwik-router-config?ssgvirtual-module variant carries the full plan for the SSG build entry; the default config(runtime server) gets the filtered plan. Dev and the client build also use the full plan, so local dev and SPA navigation are unaffected.
Why opt-in and static-only
At codegen time the build has no route-handler info (no
action$/onRequestdetection, loaders aren't optimized yet), so it cannot prove a prerendered route is safe to drop: a route can be prerendered for GET yet still need runtime SSR (e.g. a POSTaction$, whichisStaticPathdoes not intercept). The option is therefore a user certification, and v1 is limited to static (non-dynamic) routes to avoid partial-prerender edge cases. Default behavior is byte-identical (empty list).Checklist
pnpm changeAI-assisted (Opus 4.8), could use a more thorough review.