[PR #944] [MERGED] fix: support file:// URLs in cacheHandler config path #972

Closed
opened 2026-05-06 13:11:20 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/944
Author: @Divkix
Created: 4/28/2026
Status: Merged
Merged: 4/29/2026
Merged by: @james-elicx

Base: mainHead: fix/728-file-url-cache-handler


📝 Commits (3)

  • ef147e7 fix: support file:// URLs in cacheHandler config path (#728)
  • 34e6f2e fix: drop unused export on resolveCacheHandlerPathToFilesystem
  • e4c68d3 fix: resolve cacheMaxMemorySize and add cacheHandler tests

📊 Changes

2 files changed (+98 additions, -0 deletions)

View changed files

📝 packages/vinext/src/config/next-config.ts (+51 -0)
📝 tests/next-config.test.ts (+47 -0)

📄 Description

Fixes #728

Summary

  • Added cacheHandler and cacheMaxMemorySize to NextConfig type with JSDoc explaining import.meta.resolve() usage
  • Added cacheHandler to ResolvedNextConfig with file:// URL resolution
  • Created resolveCacheHandlerPathToFilesystem() utility that converts file:// URLs to filesystem paths via fileURLToPath()

What this does

When "type": "module" is set in package.json, users must use import.meta.resolve() instead of require.resolve() to resolve the cache handler path. import.meta.resolve() returns a file:// URL, which previously would break if used with path operations like path.join or path.relative. The new helper converts file:// URLs to proper filesystem paths before any path operations.

Matches Next.js commit 9a0214a1.

Test plan

  • All 58 existing next-config.test.ts tests pass (test helper updated to include new field)
  • Build, format, lint, and type checks all pass

🔄 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/944 **Author:** [@Divkix](https://github.com/Divkix) **Created:** 4/28/2026 **Status:** ✅ Merged **Merged:** 4/29/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/728-file-url-cache-handler` --- ### 📝 Commits (3) - [`ef147e7`](https://github.com/cloudflare/vinext/commit/ef147e789202cd503f0636a0a3db4e382ce657c3) fix: support file:// URLs in cacheHandler config path (#728) - [`34e6f2e`](https://github.com/cloudflare/vinext/commit/34e6f2ee59beeaa4ffe2de278a9e94cbb021d125) fix: drop unused export on resolveCacheHandlerPathToFilesystem - [`e4c68d3`](https://github.com/cloudflare/vinext/commit/e4c68d38a504f7f522006b4c421d6bc74ba1a8c3) fix: resolve cacheMaxMemorySize and add cacheHandler tests ### 📊 Changes **2 files changed** (+98 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/next-config.ts` (+51 -0) 📝 `tests/next-config.test.ts` (+47 -0) </details> ### 📄 Description Fixes #728 ## Summary - Added `cacheHandler` and `cacheMaxMemorySize` to `NextConfig` type with JSDoc explaining `import.meta.resolve()` usage - Added `cacheHandler` to `ResolvedNextConfig` with `file://` URL resolution - Created `resolveCacheHandlerPathToFilesystem()` utility that converts `file://` URLs to filesystem paths via `fileURLToPath()` ## What this does When `"type": "module"` is set in `package.json`, users must use `import.meta.resolve()` instead of `require.resolve()` to resolve the cache handler path. `import.meta.resolve()` returns a `file://` URL, which previously would break if used with path operations like `path.join` or `path.relative`. The new helper converts `file://` URLs to proper filesystem paths before any path operations. Matches Next.js commit [9a0214a1](https://github.com/vercel/next.js/commit/9a0214a12f1ed1901c4b01e84073ab854848eea0). ## Test plan - All 58 existing `next-config.test.ts` tests pass (test helper updated to include new field) - Build, format, lint, and type checks all pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:20 +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#972
No description provided.