Skip to content

refactor(router): split 4 god files into focused submodules - #228

Merged
ivogt merged 1 commit into
mainfrom
refactor/split-god-files
Feb 26, 2026
Merged

ivogt merged 1 commit into
mainfrom
refactor/split-god-files

Conversation

@ivogt

@ivogt ivogt commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • generate-route-types.ts (1,162 → ~25 lines) → route-types/ subfolder (8 modules: AST helpers, param extraction, codegen, scan filter, include resolution, per-module writer, router processing)
  • segment-resolution.ts (1,781 → ~15 lines) → segment-resolution/ subfolder (3 modules: static-store, fresh resolution, revalidation)
  • expose-internal-ids.ts (1,266 → ~371 lines) → expose-ids/ subfolder (5 modules: types, export analysis, loader/handler/router transforms)
  • router.ts (2,102 → ~1,282 lines) → 4 extracted modules: find-match.ts, lazy-includes.ts, prerender-match.ts, preview-match.ts

Pure refactor — no behavioral changes. Original files become barrel re-exports (or thin wrappers for router.ts). Follows the same pattern as the discovery/ split in #226.

Test plan

  • pnpm build-router — esbuild bundles successfully
  • pnpm --filter @rangojs/router exec tsc --noEmit — router typecheck passes
  • pnpm typecheck — full monorepo typecheck (9/9 packages)
  • pnpm lint — 0 warnings, 0 errors
  • pnpm --filter @rangojs/router test:unit — 1,624 unit tests pass
  • pnpm test — full suite (unit + 64 e2e tests, both dev and production)

Extract large files (>1000 lines) into subfolder modules with barrel
re-exports, following the same pattern as the discovery/ split.

- generate-route-types.ts (1,162 → ~25 lines) → route-types/
- segment-resolution.ts (1,781 → ~15 lines) → segment-resolution/
- expose-internal-ids.ts (1,266 → ~371 lines) → expose-ids/
- router.ts (2,102 → ~1,282 lines) → find-match, lazy-includes,
  prerender-match, preview-match modules

Pure refactor — no behavioral changes. All 1,624 unit tests and
64 e2e tests (dev + production) pass.
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.

1 participant