diff options
author | Guy Bedford <guybedford@gmail.com> | 2019-09-26 23:20:09 -0400 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2019-10-01 14:40:32 +0200 |
commit | d1f4befd09b74f9f39f14871b77c27f04c004b6b (patch) | |
tree | 7ce8f88ef9b2260612a3731c3a65f860bc980393 | |
parent | 69f26340e9814a37b205b0c31aaa10c3de28617b (diff) | |
download | node-new-d1f4befd09b74f9f39f14871b77c27f04c004b6b.tar.gz |
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>
-rw-r--r-- | lib/internal/modules/cjs/loader.js | 2 | ||||
-rw-r--r-- | test/fixtures/es-module-loaders/example-loader.mjs | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 034938e56a..eab006935b 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -1001,7 +1001,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( diff --git a/test/fixtures/es-module-loaders/example-loader.mjs b/test/fixtures/es-module-loaders/example-loader.mjs index d8e0ddcba3..ed5b0d9be5 100644 --- a/test/fixtures/es-module-loaders/example-loader.mjs +++ b/test/fixtures/es-module-loaders/example-loader.mjs @@ -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); |