next.js
51bda321 - Fix custom cache handler importing on windows (#60312)

Commit
2 years ago
Fix custom cache handler importing on windows (#60312) ### Fixing a bug ### What? Custom cache handler doesn't work on Windows ### Why? It broke in a recent fix, when adding ESM support - #59863. The problem is not new - dynamic imports consider an absolute path in Windows as a protocol: `ERR! Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'C:'` ### How? As a solution, it is necessary to explicitly indicate that it is indeed an absolute path, for example by adding a / at the beginning, but the most reliable way is to use pathToFileURL. Since the logic is repeated in 4 places - I created a common function. Fixes #58509 --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
Author
Parents
Loading