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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
guybedford authored and gibfahn committed Oct 31, 2017
1 parent e683077 commit 415fb56
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 415fb56

Please sign in to comment.