Skip to content

module: pass full URL to loader for top-level load

Rodrigo Muino Tomonari requested to merge github/fork/guybedford/href into master

This passes the full URL for the top-level "runMain" to the ESM loader, instead of the pathname. In addition the existing example loader check of the input path type is adjusted to catch the original issue.

This resolves the issue raised in https://github.com/nodejs/node/issues/29610, where the result of new URL('/C:\path') will throw.

It's more of a footgun than an actual bug, since the issue is that the expectation is that the parent URL would be passed (new URL('/C:\path', pathToFileURL(process.cwd() + path.sep)) works fine), but it seems better to be consistent in the use of file URLs input into the loader.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading