refactor: clean up fs routing internals - #182
Merged
Merged
Conversation
- nextAdapter: extract isRouteGroup/parseDynamicSegment helpers to replace four copies of segment-parsing regexes, and pull validateFilePath, pagePositionKey, and pageNode out of buildRoutes/emit - runtime: lift buildRouteDefinitions and FsRoutesApp out of the createFsRoutesEntriesWithHost closure; the slot component now flows through an explicit PageDefinitionContext instead of the host closure - tree: drop segmentsToUrl's dead normalization (inputs are already validated segments) and document the invariant instead - types: reuse MaybePromise from entryDefinition instead of redefining it - rsc/entry: deduplicate identical Response construction in renderEntryToResponse and the thrice-repeated RSC payload response No behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UbzsQZeY8hbezpvMEpusbY
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.
Internal refactoring pass over the experimental file-system routing feature. No behavior change.
Changes
fs-routes/nextAdapter.tsisRouteGroupandparseDynamicSegmenthelpers, replacing four hand-written copies of the[param]/[...param]/(group)segment-parsing regexes acrossvalidateSegment,urlSegment, andbuildRoutes.validateFilePath(segment validation + duplicate-param-name detection),pagePositionKey(route-conflict normalization), andpageNodeout ofbuildRoutes/emit, so the main loop reads as classify → validate → detect conflicts → insert.fs-routes/runtime.tsxbuildRouteDefinitionsandFsRoutesApp(~90 lines) out of thecreateFsRoutesEntriesWithHostclosure to module level; the slot component now flows through an explicitPageDefinitionContextinstead of being captured fromhost. The factory now contains only enumeration, caching, and the entries generator.fs-routes/tree.tssegmentsToUrl's dead slash-normalization chain (inputs are already validated, non-empty segments) and document the invariant instead.fs-routes/types.tsMaybePromisefromentryDefinition.tsinstead of redefining it.rsc/entry.tsxResponseconstruction in both SSR branches ofrenderEntryToResponse, and the thrice-repeatedtext/x-componentresponse literal inserveRSC(now arscResponsehelper).Verification
pnpm typecheck,pnpm lint,pnpm format:check: cleanfs-routingproject (production build): 17/17 passedfs-routing-devproject (dev server): 10/10 passed🤖 Generated with Claude Code
https://claude.ai/code/session_01UbzsQZeY8hbezpvMEpusbY
Generated by Claude Code