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

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: nodejs/node#16526
Fixes: nodejs/node#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 addaleax committed Dec 7, 2017
1 parent 1c34ab7 commit b0c99a3
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 @@ -436,7 +436,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 b0c99a3

Please sign in to comment.