Files
node/lib
Maruthan G 9d94b6548a test_runner: mock dual-package with conditional exports
When `mock.module()` targets a package whose `exports` field maps
`import` and `require` to different files, the ESM resolver and the
CJS resolver disagree on the resolved path. Only the ESM path was
registered in `mockMap`, so `require()` of the mocked specifier
bypassed the mock and loaded the real CJS module.

Resolve the specifier through `Module._resolveFilename` from the
caller's directory in addition to the existing ESM resolution. When
the two paths differ, register the CJS path as a second key in
`mockMap` and invalidate `Module._cache[cjsPath]`, restoring it on
`restore()`. Single-resolution packages keep their existing behavior.

Fixes: https://github.com/nodejs/node/issues/58231
Signed-off-by: Maruthan G <maruthang4@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62943
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-08-21 13:09:19 -07:00
..
…
…
…
2026-07-05 08:04:44 +00:00
…
2026-08-06 09:25:51 +00:00
2026-04-05 10:12:21 +00:00
2026-06-21 19:42:03 +00:00
2026-05-31 12:49:51 -07:00
2026-08-13 15:25:11 +00:00
…
2025-12-10 16:12:28 +00:00
…
2025-12-22 16:14:46 +00:00
2026-07-25 23:56:46 -07:00
…
2026-02-21 16:30:23 +00:00
…
2026-04-01 10:09:41 +00:00
…
2026-04-26 19:36:36 +00:00
2026-05-23 18:43:31 +00:00