Skip to content

Commit 819a647

Browse files
ZYSzysBethGriggs
authored andcommitted
esm: fix esm load bug
Fixes: #25482 Backport-PR-URL: #27874 PR-URL: #25491 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 6e849c3 commit 819a647

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,11 @@ Module.prototype.load = function(filename) {
661661
// create module entry at load time to snapshot exports correctly
662662
const exports = this.exports;
663663
if (module !== undefined) { // called from cjs translator
664-
module.reflect.onReady((reflect) => {
665-
reflect.exports.default.set(exports);
666-
});
664+
if (module.reflect) {
665+
module.reflect.onReady((reflect) => {
666+
reflect.exports.default.set(exports);
667+
});
668+
}
667669
} else { // preemptively cache
668670
ESMLoader.moduleMap.set(
669671
url,

0 commit comments

Comments
 (0)