Skip to content

refactor(app-router): build discoverSiblingInterceptingRoutes paths with path.posix - #2306

Merged
james-elicx merged 2 commits into
cloudflare:mainfrom
shulaoda:06-24-refactor_app-router_build_discoversiblinginterceptingroutes_paths_with_path.posix
Jun 30, 2026
Merged

refactor(app-router): build discoverSiblingInterceptingRoutes paths with path.posix#2306
james-elicx merged 2 commits into
cloudflare:mainfrom
shulaoda:06-24-refactor_app-router_build_discoversiblinginterceptingroutes_paths_with_path.posix

Conversation

@shulaoda

Copy link
Copy Markdown
Contributor

What

In discoverSiblingInterceptingRoutes, derive the owner and child directories with path.posix.*, and document that appDir and each route's pagePath / routePath must be forward-slash:

  • routeDir: normalizePathSeparators(path.dirname(filePath))path.posix.dirname(filePath).
  • childDir: path.join(dir, entry.name)path.posix.join(dir, entry.name).

Why

A route's pagePath / routePath is now a forward-slash canonical id, and appDir is forward-slash by the route-graph contract. So path.posix.dirname(filePath) yields the forward-slash owner directory directly — the old normalizePathSeparators(path.dirname(...)) only existed because filePath used to be native (backslash) on Windows. findOwnerRouteForDir compares in forward-slash space, so routeDir must be forward-slash, which it now is without the normalization pass. The marker-scan childDir switches to path.posix.join for the same reason.

How

  • routeDir uses path.posix.dirname(filePath) (drops normalizePathSeparators and the now-stale comment).
  • childDir uses path.posix.join(dir, entry.name).
  • Doc note: appDir / pagePath / routePath must be forward-slash; owner dirs come from pagePath / routePath matched against appDir-relative path.posix.* paths.

Testing

  • vp check packages/vinext/src/routing/app-route-graph.ts — format, lint, and typecheck clean.
  • No-op on POSIX (path.posix === path). On Windows, given the forward-slash pagePath / routePath / appDir, routeDir and childDir are identical to the previous normalized results. Behavior-preserving, hence refactor.

@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2306
npm i https://pkg.pr.new/vinext@2306

commit: ba41bdb

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared ba41bdb against base c8aef02 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 1 regressed · 5 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 124.0 KB 124.0 KB ⚫ +0.0%
Client entry size (gzip) vinext 118.8 KB 118.8 KB ⚫ +0.0%
Dev server cold start vinext 1.94 s 1.96 s ⚫ +1.0%
Production build time vinext 2.28 s 2.32 s 🔴 +1.6%
RSC entry closure size (gzip) vinext 95.2 KB 95.2 KB ⚫ +0.0%
Server bundle size (gzip) vinext 161.5 KB 161.5 KB ⚫ +0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx
james-elicx merged commit c54614f into cloudflare:main Jun 30, 2026
49 checks passed
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