Skip to content

refactor: clean up fs routing internals - #182

Merged
uhyo merged 1 commit into
masterfrom
claude/fs-routing-refactor-c1gxcd
Aug 30, 2026
Merged

refactor: clean up fs routing internals#182
uhyo merged 1 commit into
masterfrom
claude/fs-routing-refactor-c1gxcd

Conversation

@uhyo

@uhyo uhyo commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Internal refactoring pass over the experimental file-system routing feature. No behavior change.

Changes

fs-routes/nextAdapter.ts

  • Extract isRouteGroup and parseDynamicSegment helpers, replacing four hand-written copies of the [param] / [...param] / (group) segment-parsing regexes across validateSegment, urlSegment, and buildRoutes.
  • Pull validateFilePath (segment validation + duplicate-param-name detection), pagePositionKey (route-conflict normalization), and pageNode out of buildRoutes/emit, so the main loop reads as classify → validate → detect conflicts → insert.

fs-routes/runtime.tsx

  • Lift buildRouteDefinitions and FsRoutesApp (~90 lines) out of the createFsRoutesEntriesWithHost closure to module level; the slot component now flows through an explicit PageDefinitionContext instead of being captured from host. The factory now contains only enumeration, caching, and the entries generator.

fs-routes/tree.ts

  • Remove segmentsToUrl's dead slash-normalization chain (inputs are already validated, non-empty segments) and document the invariant instead.

fs-routes/types.ts

  • Reuse MaybePromise from entryDefinition.ts instead of redefining it.

rsc/entry.tsx

  • Deduplicate the identical Response construction in both SSR branches of renderEntryToResponse, and the thrice-repeated text/x-component response literal in serveRSC (now a rscResponse helper).

Verification

  • Unit tests: 148 passed
  • pnpm typecheck, pnpm lint, pnpm format:check: clean
  • E2E fs-routing project (production build): 17/17 passed
  • E2E fs-routing-dev project (dev server): 10/10 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01UbzsQZeY8hbezpvMEpusbY


Generated by Claude Code

- 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
@uhyo
uhyo merged commit c459e2d into master Aug 30, 2026
2 checks passed
@uhyo
uhyo deleted the claude/fs-routing-refactor-c1gxcd branch August 30, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants