Skip to content

Commit c42ab99

Browse files
guybedfordTrott
authored andcommitted
module: pass full URL to loader for top-level load
PR-URL: #29736 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: David Carlier <[email protected]>
1 parent 1a3bf4f commit c42ab99

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/internal/modules/cjs/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ Module.runMain = function() {
10021002
// Load the main module--the command line argument.
10031003
if (experimentalModules) {
10041004
asyncESM.loaderPromise.then((loader) => {
1005-
return loader.import(pathToFileURL(process.argv[1]).pathname);
1005+
return loader.import(pathToFileURL(process.argv[1]).href);
10061006
})
10071007
.catch((e) => {
10081008
internalBinding('errors').triggerUncaughtException(

test/fixtures/es-module-loaders/example-loader.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export function resolve(specifier, parentModuleURL = baseURL /*, defaultResolve
1515
format: 'builtin'
1616
};
1717
}
18-
if (/^\.{0,2}[/]/.test(specifier) !== true && !specifier.startsWith('file:')) {
18+
if (/^\.{1,2}[/]/.test(specifier) !== true && !specifier.startsWith('file:')) {
1919
// For node_modules support:
2020
// return defaultResolve(specifier, parentModuleURL);
2121
throw new Error(
22-
`imports must begin with '/', './', or '../'; '${specifier}' does not`);
22+
`imports must be URLs or begin with './', or '../'; '${specifier}' does not`);
2323
}
2424
const resolved = new url.URL(specifier, parentModuleURL);
2525
const ext = path.extname(resolved.pathname);

0 commit comments

Comments
 (0)