Skip to content

fix(routing): use normalizePathSeparators(path.relative) instead of path.posix.relative - #2308

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

fix(routing): use normalizePathSeparators(path.relative) instead of path.posix.relative#2308
james-elicx merged 2 commits into
cloudflare:mainfrom
shulaoda:06-24-fix_routing_use_normalizepathseparators_path.relative_instead_of_path.posix.relative

Conversation

@shulaoda

Copy link
Copy Markdown
Contributor

What

Replace every path.posix.relative(a, b) with normalizePathSeparators(path.relative(a, b)), and drop the now-stale path.posix.relative mentions from the surrounding doc comments:

  • routing/app-route-graph.ts: the parallel-slot ownerSegments and slot key.
  • check.ts: scanImports' relFile and checkConventions' rel.
  • plugins/og-assets.ts: the chunk-relative wasm URL.

Why

path.posix.relative treats its inputs as plain POSIX strings, so on Windows absolute paths it gets the drive/case semantics wrong:

inputs path.posix.relative normalizePathSeparators(path.relative(...))
C:/App vs C:/app/dashboard ../app/dashboard dashboard
c:/app vs C:/app/dashboard ../../C:/app/dashboard dashboard
C:/app vs D:/other/x ../../D:/other/x D:/other/x

Windows filesystems are case-insensitive and drive-qualified, so an appDir / root whose casing or drive differs from a scanned path would yield a corrupt relative path or key. path.relative is path.win32.relative on Windows and handles all of that correctly; normalizing its result back to forward slashes keeps the canonical id form. For og-assets, the operands are bundle-relative paths (no drive), so the two forms are equivalent — it is unified anyway so there is no special case to reason about later.

How

  • Swapped the five path.posix.relative calls for normalizePathSeparators(path.relative(...)).
  • Re-added the normalizePathSeparators import to check.ts and added it to og-assets.ts.
  • Removed the path.posix.relative clauses from the affected doc comments (kept the path.posix.join notes).

Testing

  • vp check packages/vinext/src/routing/app-route-graph.ts packages/vinext/src/check.ts packages/vinext/src/plugins/og-assets.ts — format, lint, and typecheck clean.
  • No-op on POSIX (path.relative === path.posix.relative, normalizePathSeparators returns its input). On Windows, relative paths are now computed with drive/case awareness, fixing corrupt slot keys / report paths when casing or drive differs.

@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@2308
npm i https://pkg.pr.new/vinext@2308

commit: d60a786

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared d60a786 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 2.49 s 2.48 s ⚫ -0.2%
Production build time vinext 2.87 s 2.94 s 🔴 +2.3%
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

…s_path.relative_instead_of_path.posix.relative
@james-elicx
james-elicx merged commit 795d568 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