Skip to content

Commit

Permalink
module: fix extension lookups for top-level main
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
guybedford authored and gibfahn committed Oct 30, 2017
1 parent 7a01402 commit a0effd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ Module._load = function(request, parent, isMain) {
ESMLoader.hook(hooks);
}
}
await ESMLoader.import(getURLFromFilePath(request).href);
await ESMLoader.import(getURLFromFilePath(request).pathname);
})()
.catch((e) => {
console.error(e);
Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-module-main-extension-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';
require('../common');
const { execFileSync } = require('child_process');

const node = process.argv[0];

execFileSync(node, ['--experimental-modules', 'test/es-module/test-esm-ok']);

0 comments on commit a0effd3

Please sign in to comment.