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 <myles.borins@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent e683077 commit 415fb56

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
@@ -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);
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)