Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Commit af2b416

Browse files
guybedfordQard
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: nodejs/node#16526 Fixes: nodejs/node#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 6e5232c commit af2b416

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)