Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ function loadCJSModule(module, source, url, filename, isMain) {
specifier = `${pathToFileURL(path)}`;
}

// FIXME(node:59666) Currently, the ESM loader re-invents require() here for imported CJS and this
// requires a separate cache to be populated as well as introducing several quirks. This is not ideal.
// NOTE: This re-invented require() is only used on the loader-hook worker thread.
// On the main thread, the authentic require() is used instead (fixed by #60380).
// Remaining quirks on the loader-hook thread: lacks require.cache, require.extensions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Remaining quirks on the loader-hook thread: lacks require.cache, require.extensions.

There are a lot more quirks than this: https://nodejs.org/api/module.html#caveats-of-asynchronous-customization-hooks - the lack of require properties were less like quirks but intentional whennoeole people thought they should be eventually deprecated AFAIK.

const request = { specifier, attributes: importAttributes, phase: kEvaluationPhase, __proto__: null };
const job = cascadedLoader.getOrCreateModuleJob(url, request, kRequireInImportedCJS);
job.runSync();
Expand Down