Skip to content

Commit 89fda94

Browse files
ZYSzystargos
authored andcommitted
esm: fix esm load bug
Fixes: #25482 PR-URL: #25491 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent da4a379 commit 89fda94

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/internal/modules/cjs/loader.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,11 @@ Module.prototype.load = function(filename) {
648648
// Create module entry at load time to snapshot exports correctly
649649
const exports = this.exports;
650650
if (module !== undefined) { // Called from cjs translator
651-
module.reflect.onReady((reflect) => {
652-
reflect.exports.default.set(exports);
653-
});
651+
if (module.reflect) {
652+
module.reflect.onReady((reflect) => {
653+
reflect.exports.default.set(exports);
654+
});
655+
}
654656
} else { // preemptively cache
655657
ESMLoader.moduleMap.set(
656658
url,

0 commit comments

Comments
 (0)