Skip to content
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

Open
wants to merge 3 commits into
base: canary
Choose a base branch
from

Conversation

chrisweb
Copy link
Contributor

@chrisweb chrisweb commented Jan 6, 2025

@ijjk ijjk added the type: next label Jan 6, 2025
@ijjk
Copy link
Member

ijjk commented Jan 6, 2025

Allow CI Workflow Run

  • approve CI run for commit: 10634ba

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@ijjk
Copy link
Member

ijjk commented Jan 6, 2025

Allow CI Workflow Run

  • approve CI run for commit: 85d7036

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Copy link
Contributor

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?

Copy link
Contributor Author

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mdx js loader: paths must be valid file:// URLs (windows only)
3 participants