Skip to content

Commit

Permalink
fixed an issue with external globals defined in CJS that happen to ha…
Browse files Browse the repository at this point in the history
…ve a 'default' export
  • Loading branch information
beatfactor committed Jan 10, 2023
1 parent ee6cc08 commit c998ac3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/requireModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function (fullpath) {
return import(fullpath).then(result => (result.default || {}));
}

if (exported && Object.prototype.hasOwnProperty.call(exported, 'default')) {
if (exported && Object.prototype.hasOwnProperty.call(exported, 'default') && Object.keys(exported).length === 1) {
return exported.default;
}

Expand Down
2 changes: 2 additions & 0 deletions test/extra/external-globals.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const assert = require('assert');

module.exports = {
'default': {},

async before() {
this.isFungus = true;
},
Expand Down

0 comments on commit c998ac3

Please sign in to comment.