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 <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 Qard committed Nov 2, 2017
1 parent 744691f commit 88d1802
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 88d1802

Please sign in to comment.