Skip to content

Commit

Permalink
esm: fix esm load bug
Browse files Browse the repository at this point in the history
Fixes: #25482

PR-URL: #25491
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
ZYSzys authored and targos committed May 14, 2019
1 parent da4a379 commit 89fda94
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 @@ -648,9 +648,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 89fda94

Please sign in to comment.