uwdata / living-papers

Authoring tools for scholarly communication. Create interactive web pages or formal research papers from markdown source.
BSD 3-Clause "New" or "Revised" License
127 stars 10 forks source link

fix: Resolve transforms with Windows paths #91

Closed TwoTau closed 1 year ago

TwoTau commented 1 year ago

Windows absolute file paths strike again :(

Before this PR, adding a transform in a project's package.json like this:

"transforms": [
  {
    "name": "my-transform",
    "file": "src/my-transform.js"
  }
]

would cause this error (my drive is named Q:):

Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'q:'

because of https://github.com/nodejs/node/issues/31710.

This PR just uses the standard solution of pathToFileURL to load custom transforms correctly.

TwoTau commented 1 year ago

I think this is the only place we import an absolute path from path.resolve since everything else works for me