-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggested fix for issue #74564 #74565
base: canary
Are you sure you want to change the base?
Conversation
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you just need pathToFileURL(path) here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had forgotten to add the require for pathToFile which I fixed just now.
Regarding your comment, I'm not sure I understand what you suggest. I mean I'm not sure to what line of the code your comment is referring. Do you mean moving pathToFileURL into the interopDefault function?
Do you mean using pathToFileUrl without also using "require.resolve"?
- the
importPlugin
function gets the plugin value (and the project root path) - the
plugin
value is an array, where the first value is the mdx plugin name (the package name) as a string and the second value (which is optional) contains the plugin options (which need to be serializable) - using
require.resolve
we get the path of the plugin (package) by passing the name and project root path - then comes my change which fixes the path we get from previous step and turns it into a windows file URL using
pathToFileURL
(if the platform is windows) - now the import function is not throwing an error anymore (on windows) because the value we pass to import is now a valid file:// URL and not a string like 'c:/PATH_TO_ESM_PACKAGE'
Fixes #74564
The idea for the fix is from fbf9e12#diff-907b7be0cfc75bd37773e5ebc38d1deffa40861b8ac1cde92e4992e284a1ee59R1221 I use the same nodejs pathToFileURL (https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/find-config.ts#L74)