fix: fail on fs-route pages generating the same URL, dedupe duplicate params - #179
Merged
Merged
Conversation
… params Audit follow-ups for the file-system router: - collectStaticPaths() now collapses duplicate params returned by one generateStaticParams() into a single page, and fails the build with an error naming both files when two different routes generate the same URL (e.g. a static page next to a dynamic sibling resolving to it). Both cases previously surfaced only as a generic "Duplicate entry path" build error, and not at all on the dev server. - The fs-routes chunk host now registers payloads through a shared registerDeferredPayload() helper extracted from defer(), so dev payload file names include the sanitized route name for debugging instead of a bare UUID, and the ID-generation logic lives in one place. - runtime.tsx references imported ComponentType/ReactNode types instead of the React UMD-global namespace, matching the repo's explicit-type-import convention. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012FqKsH47SihjqPZQ19ioR2
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.
Follow-ups from an audit of the experimental file-system router. No major bugs found; this fixes the minor issues that turned up.
Changes
Detect colliding generated URLs, dedupe duplicate params (
tree.ts)Previously, a static page next to a dynamic sibling whose
generateStaticParams()resolves to the same URL (e.g.blog/hello/page.tsx+blog/[slug]returning"hello"), or onegenerateStaticParams()returning the same params twice, produced duplicate pages. The build only failed later with a genericDuplicate entry path: "blog/hello.html"error, and the dev server silently served whichever entry came first.collectStaticPaths()now:Documented in the JSDoc for
generateStaticParamsand in the file-system routing docs page.Share deferred-payload ID generation (
defer.tsx,fs-routes/entries.tsx)The fs-routes chunk host duplicated
defer()'s payload-ID generation but skipped the part that includes the sanitized debug name in the dev payload file name, so fs-route chunks showed up as bare UUIDs in dev tools. Extracted a sharedregisterDeferredPayload()helper used by both, so dev chunk payloads are now named likefs-route_lang_page_tsx_en-<uuid>and the logic lives in one place.Type-import consistency (
runtime.tsx)Replaced
React.ComponentType/React.ReactNodeUMD-global namespace references with the types the file already imports explicitly, matching the repo'sverbatimModuleSyntaxconvention.Audit notes (no change needed)
@funstack/router1.4.0 that the matcher backtracks out of a matched parent whose children all fail (sibling group layouts sharing a path can't shadow each other's pages), and that match params aredecodeURIComponent-ed, so percent-encoded URLs round-trip to build-time param values on soft navigation.[...],[[slug]], bracket-containing literal directory names — URLPattern treats[literally) and found no holes.evictStalepolicy (Dev server: deferRegistry grows unboundedly across requests #144), with the hard-navigation fallback covering evicted chunks.Testing
pnpm typecheck,pnpm lint,pnpm format:check, and the full monorepo build pass🤖 Generated with Claude Code
https://claude.ai/code/session_012FqKsH47SihjqPZQ19ioR2
Generated by Claude Code