node/test/fixtures/es-modules/esm-in-require-cache/require-esm.cjs
Joyee Cheung c46260284c
module: only put directly require-d ESM into require.cache
This reduces the impact of
https://redirect.github.com/nodejs/node/pull/59679
by delaying the require.cache population of ESM until they
are directly required. After that, it's necessary for them
to be in the cache to maintain correctness.

PR-URL: https://github.com/nodejs/node/pull/59874
Refs: https://github.com/nodejs/node/issues/59868
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2025-09-17 13:13:59 +00:00

9 lines
224 B
JavaScript

const path = require('path');
const name = require('./esm.mjs').name;
exports.name = name;
const filename = path.join(__dirname, 'esm.mjs');
const cache = require.cache[filename];
exports.cache = require.cache[filename];