Skip to content

Commit 7e5e60b

Browse files
authored
module: remove duplicated checks from _resolveFilename
PR-URL: #62729 Reviewed-By: Jacob Smith <jacob@frende.me>
1 parent bd8345b commit 7e5e60b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/internal/modules/cjs/loader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,8 +1426,9 @@ Module._resolveFilename = function(request, parent, isMain, options) {
14261426
paths = Module._resolveLookupPaths(request, parent);
14271427
}
14281428

1429-
if (request[0] === '#' && (parent?.filename || parent?.id === '<repl>')) {
1430-
const parentPath = parent?.filename ?? process.cwd() + path.sep;
1429+
const parentPath = trySelfParentPath(parent);
1430+
1431+
if (request[0] === '#' && (parent.filename || parent.id === '<repl>')) {
14311432
const pkg = packageJsonReader.getNearestParentPackageJSON(parentPath);
14321433
if (pkg?.data.imports != null) {
14331434
try {
@@ -1447,7 +1448,6 @@ Module._resolveFilename = function(request, parent, isMain, options) {
14471448
}
14481449

14491450
// Try module self resolution first
1450-
const parentPath = trySelfParentPath(parent);
14511451
const selfResolved = trySelf(parentPath, request, conditions);
14521452
if (selfResolved) {
14531453
const cacheKey = request + '\x00' +

0 commit comments

Comments
 (0)