Skip to content

Commit 415fb56

Browse files
guybedfordgibfahn
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 e683077 commit 415fb56

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ Module._load = function(request, parent, isMain) {
452452
ESMLoader.hook(hooks);
453453
}
454454
}
455-
await ESMLoader.import(getURLFromFilePath(request).href);
455+
await ESMLoader.import(getURLFromFilePath(request).pathname);
456456
})()
457457
.catch((e) => {
458458
console.error(e);
Lines changed: 7 additions & 0 deletions
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)