[PR #130] [MERGED] fix: use fileURLToPath for metadata-routes import in RSC entry #336

Closed
opened 2026-05-06 12:39:17 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/130
Author: @gentritbiba
Created: 2/26/2026
Status: Merged
Merged: 2/27/2026
Merged by: @FredKSchott

Base: mainHead: fix/spaces-in-path-metadata-routes


📝 Commits (1)

  • e75028c fix: use fileURLToPath for metadata-routes import in RSC entry

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 packages/vinext/src/server/app-dev-server.ts (+2 -1)

📄 Description

Summary

  • Use fileURLToPath() instead of URL.pathname when generating the metadata-routes import path in the virtual RSC entry
  • URL.pathname returns percent-encoded strings (e.g. %20 for spaces), which Vite cannot resolve as filesystem paths
  • This caused all App Router / RSC / nextjs-compat tests to fail (19/50 test files, 271 tests) when the project lives in a directory with spaces — common on macOS with iCloud Drive, Google Drive, OneDrive, etc.

Change

One-line fix in packages/vinext/src/server/app-dev-server.ts:

-new URL("./metadata-routes.js", import.meta.url).pathname.replace(/\\/g, "/")
+fileURLToPath(new URL("./metadata-routes.js", import.meta.url)).replace(/\\/g, "/")

This pattern is already used correctly elsewhere in the codebase (cloudflare/tpr.ts:613).

Test plan

  • Verified all 50 test files pass (2011 tests) on a path without spaces
  • Verified all 50 test files pass (2011 tests) on a path with spaces (~/Code/test spaces/vinext)
  • Confirmed this was the root cause by tracing the Vite error: Failed to load url .../metadata-routes.js in virtual:vinext-rsc-entry

Fixes #129


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/130 **Author:** [@gentritbiba](https://github.com/gentritbiba) **Created:** 2/26/2026 **Status:** ✅ Merged **Merged:** 2/27/2026 **Merged by:** [@FredKSchott](https://github.com/FredKSchott) **Base:** `main` ← **Head:** `fix/spaces-in-path-metadata-routes` --- ### 📝 Commits (1) - [`e75028c`](https://github.com/cloudflare/vinext/commit/e75028c689a86edd38bf0ef85d6a2d68d61f63a4) fix: use fileURLToPath for metadata-routes import in RSC entry ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/app-dev-server.ts` (+2 -1) </details> ### 📄 Description ## Summary - Use `fileURLToPath()` instead of `URL.pathname` when generating the metadata-routes import path in the virtual RSC entry - `URL.pathname` returns percent-encoded strings (e.g. `%20` for spaces), which Vite cannot resolve as filesystem paths - This caused **all App Router / RSC / nextjs-compat tests to fail** (19/50 test files, 271 tests) when the project lives in a directory with spaces — common on macOS with iCloud Drive, Google Drive, OneDrive, etc. ## Change One-line fix in `packages/vinext/src/server/app-dev-server.ts`: ```diff -new URL("./metadata-routes.js", import.meta.url).pathname.replace(/\\/g, "/") +fileURLToPath(new URL("./metadata-routes.js", import.meta.url)).replace(/\\/g, "/") ``` This pattern is already used correctly elsewhere in the codebase (`cloudflare/tpr.ts:613`). ## Test plan - [x] Verified all 50 test files pass (2011 tests) on a path without spaces - [x] Verified all 50 test files pass (2011 tests) on a path **with** spaces (`~/Code/test spaces/vinext`) - [x] Confirmed this was the root cause by tracing the Vite error: `Failed to load url .../metadata-routes.js in virtual:vinext-rsc-entry` Fixes #129 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39:17 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#336
No description provided.