Skip to content

Commit

Permalink
fixup simpler __cjsModule gate
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jul 16, 2024
1 parent 9ce2ccc commit 3d7d1eb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,11 @@ function loadESMFromCJS(mod, filename) {
// createRequiredModuleFacade() to `wrap` which is a ModuleWrap wrapping
// over the original module.

// We don't do this to modules that don't have default exports to avoid
// the unnecessary overhead. If __esModule is already defined, we will
// also skip the extension to allow users to override it.
if (namespace.__cjsModule === true && ObjectHasOwn(namespace, 'default')) {
// We don't do this to modules that are marked as CJS ESM or that
// don't have default exports to avoid the unnecessary overhead.
// If __esModule is already defined, we will also skip the extension
// to allow users to override it.
if (namespace.__cjsModule) {
mod.exports = namespace.default;
} else if (!ObjectHasOwn(namespace, 'default') || ObjectHasOwn(namespace, '__esModule')) {
mod.exports = namespace;
Expand Down

0 comments on commit 3d7d1eb

Please sign in to comment.