module: pass full URL to loader for top-level load
PR-URL: https://github.com/nodejs/node/pull/29736 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
This commit is contained in:
parent
1a3bf4f935
commit
c42ab995c1
@ -1002,7 +1002,7 @@ Module.runMain = function() {
|
||||
// Load the main module--the command line argument.
|
||||
if (experimentalModules) {
|
||||
asyncESM.loaderPromise.then((loader) => {
|
||||
return loader.import(pathToFileURL(process.argv[1]).pathname);
|
||||
return loader.import(pathToFileURL(process.argv[1]).href);
|
||||
})
|
||||
.catch((e) => {
|
||||
internalBinding('errors').triggerUncaughtException(
|
||||
|
@ -15,11 +15,11 @@ export function resolve(specifier, parentModuleURL = baseURL /*, defaultResolve
|
||||
format: 'builtin'
|
||||
};
|
||||
}
|
||||
if (/^\.{0,2}[/]/.test(specifier) !== true && !specifier.startsWith('file:')) {
|
||||
if (/^\.{1,2}[/]/.test(specifier) !== true && !specifier.startsWith('file:')) {
|
||||
// For node_modules support:
|
||||
// return defaultResolve(specifier, parentModuleURL);
|
||||
throw new Error(
|
||||
`imports must begin with '/', './', or '../'; '${specifier}' does not`);
|
||||
`imports must be URLs or begin with './', or '../'; '${specifier}' does not`);
|
||||
}
|
||||
const resolved = new url.URL(specifier, parentModuleURL);
|
||||
const ext = path.extname(resolved.pathname);
|
||||
|
Loading…
x
Reference in New Issue
Block a user