From b3980a0579f827b41c8ef732afe681da3a9308b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 15 Aug 2023 09:10:54 +0200 Subject: [PATCH] fix(require): use canonicalized path for loading content (#20133) --- ext/node/polyfills/01_require.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js index 092e7490a3..eb845f2375 100644 --- a/ext/node/polyfills/01_require.js +++ b/ext/node/polyfills/01_require.js @@ -833,7 +833,9 @@ Module._resolveFilename = function ( isMain, parentPath, ); - if (filename) return filename; + if (filename) { + return ops.op_require_real_path(filename); + } const requireStack = []; for (let cursor = parent; cursor; cursor = moduleParentCache.get(cursor)) { ArrayPrototypePush(requireStack, cursor.filename || cursor.id); @@ -891,7 +893,7 @@ Module.prototype.load = function (filename) { ); } - Module._extensions[extension](this, filename); + Module._extensions[extension](this, this.filename); this.loaded = true; // TODO: do caching