Skip to content

Commit

Permalink
suggested fix for issue #74564
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisweb committed Jan 6, 2025
1 parent c94fdef commit 10634ba
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next-mdx/mdx-js-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ function interopDefault(mod) {

async function importPlugin(plugin, projectRoot) {
if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
const path = require.resolve(plugin[0], { paths: [projectRoot] })
plugin[0] = interopDefault(
await import(require.resolve(plugin[0], { paths: [projectRoot] }))
// "use pathToFileUrl to make esm import()s work with absolute windows paths":
// on windows import("C:\\path\\to\\file") is not valid, so we need to use file:// URLs
// https://github.com/vercel/next.js/commit/fbf9e12de095e0237d4ba4aa6139d9757bd20be9
await import((process.platform === 'win32') ? pathToFileURL(path) : path)
)
}
return plugin
Expand Down

0 comments on commit 10634ba

Please sign in to comment.