Skip to content

Commit cadc47f

Browse files
guybedfordtargos
authored andcommitted
module: fix extension lookups for top-level main
The reason is that absolute URLs do not go through extension and index checks. By switching to an absolute path, the resolver still applies extensions properly to the top-level main. PR-URL: #16526 Fixes: #16476 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent d853758 commit cadc47f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ Module._load = function(request, parent, isMain) {
436436
ESMLoader.hook(hooks);
437437
}
438438
}
439-
await ESMLoader.import(getURLFromFilePath(request).href);
439+
await ESMLoader.import(getURLFromFilePath(request).pathname);
440440
})()
441441
.catch((e) => {
442442
console.error(e);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
require('../common');
3+
const { execFileSync } = require('child_process');
4+
5+
const node = process.argv[0];
6+
7+
execFileSync(node, ['--experimental-modules', 'test/es-module/test-esm-ok']);

0 commit comments

Comments
 (0)