Files
9a0214a12f fix: handle file:// URLs from import.meta.resolve in cache handler path (fixes #73796) (#90370)
## Summary

Fixes #73796

### The Bug

When "type": "module" is in package.json, users cannot use
require.resolve() for the cache handler path. They must use
import.meta.resolve() instead, which returns a file:// URL. Next.js was
concatenating this URL with .next/ producing invalid paths and
ERR_MODULE_NOT_FOUND errors.

### The Fix

1. resolveCacheHandlerPathToFilesystem() - New helper that converts
file:// URLs to proper filesystem paths using Node's fileURLToPath()
2. formatDynamicImportPath() - Now calls
resolveCacheHandlerPathToFilesystem() before any path operations
3. Applied in collect-build-traces.ts, build/index.ts, and
build/swc/index.ts

This ensures ESM import.meta.resolve() cache handler paths work
correctly in all code paths.

---------

Co-authored-by: JJ Kasper <[email protected]>
2026-03-30 23:53:41 +00:00
..
…