Skip to content

Commit

Permalink
esm: fix esm load bug
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ZYSzys authored and BethGriggs committed Jun 6, 2019
1 parent 6e849c3 commit 819a647
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,11 @@ Module.prototype.load = function(filename) {
// create module entry at load time to snapshot exports correctly
const exports = this.exports;
if (module !== undefined) { // called from cjs translator
module.reflect.onReady((reflect) => {
reflect.exports.default.set(exports);
});
if (module.reflect) {
module.reflect.onReady((reflect) => {
reflect.exports.default.set(exports);
});
}
} else { // preemptively cache
ESMLoader.moduleMap.set(
url,
Expand Down

0 comments on commit 819a647

Please sign in to comment.