feat: fail the build for dynamic fs-routes without generateStaticParams#136
Merged
Conversation
Previously a dynamic route without generateStaticParams() was skipped with a warning claiming it "still works on the client via the SPA fallback". That claim was only half-true: RSC payloads are serialized at build time with each entry's concrete params, so a server-component page reached via the SPA fallback renders with empty params, and the fallback itself requires host-level rewrite configuration. Since a static site can only serve pages enumerated at build time, the missing export is now a build error instead of a silent skip. The unused onWarn parameter is removed from collectStaticPaths, and the docs no longer advertise the SPA fallback for dynamic routes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0183g2LXhE2PfPpg5KTmFLrM
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.
Summary
A dynamic route (e.g.
blog/[slug]/page.tsx) without agenerateStaticParams()export now fails the build instead of being skipped with a warning.Motivation
The previous warning claimed the route "still works on the client via the SPA fallback", but that claim was only half-true:
"use client"pages readinguseRouteParams()would get correct values.Since a static site can only serve pages enumerated at build time, failing loudly is more honest than silently producing a route that mostly doesn't work.
Changes
collectStaticPaths()throws a descriptive error for a dynamic route withoutgenerateStaticParams(); its now-unusedonWarnparameter is removed (fs-routes is@experimentaland exempt from semver).FsRouteModule.generateStaticParamsJSDoc documents the export as required for dynamic routes.FileSystemRouting.mdx) document the build failure and drop the SPA-fallback claim.Note
Technically breaking for anyone relying on the old skip behavior, though fs-routes is documented as experimental and not subject to semver.
🤖 Generated with Claude Code
https://claude.ai/code/session_0183g2LXhE2PfPpg5KTmFLrM
Generated by Claude Code