diff options
author | ZYSzys <zyszys98@gmail.com> | 2019-05-13 17:37:34 +0800 |
---|---|---|
committer | ZYSzys <zyszys98@gmail.com> | 2019-05-14 16:15:28 +0800 |
commit | 6fe369286a81fb4fc0190dc04ee16a466c7e0760 (patch) | |
tree | 0f637b70aba1fa5d067eda84e1b52c1e7afc545f | |
parent | 523a9fbcb43c96f159fae7bd28b0f8fd51dd9ca5 (diff) | |
download | node-new-6fe369286a81fb4fc0190dc04ee16a466c7e0760.tar.gz |
esm: fix esm load bug
Fixes: https://github.com/nodejs/node/issues/25482
PR-URL: https://github.com/nodejs/node/pull/25491
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
-rw-r--r-- | lib/internal/modules/cjs/loader.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 428f5452c6..5d4ae26c02 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -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, |