Fix bug when multiple-levels of nested exports when bundled have a boolean .default value

This commit is contained in:
Jarred Sumner
2021-09-23 17:34:54 -07:00
parent 0585c86390
commit 2177dda242
2 changed files with 17 additions and 9 deletions

View File

@@ -62,14 +62,22 @@ export var __commonJS = (cb, name) => {
!mod.exports[tagSymbol] &&
Object.keys(mod.exports).length === 1
) {
mod.exports = mod.exports.default;
Object.defineProperty(mod.exports, "default", {
get() {
return mod.exports;
},
enumerable: true,
configurable: true,
});
// if mod.exports.default === true this won't work because we can't define a property on a boolean
if (
typeof mod.exports.default === "object" ||
typeof mod.exports.default === "function"
) {
mod.exports = mod.exports.default;
Object.defineProperty(mod.exports, "default", {
get() {
return mod.exports;
},
enumerable: true,
configurable: true,
});
}
// If it's a namespace export without .default, pretend .default is the same as mod.exports
} else if (
(kind === "function" || kind === "object") &&

View File

@@ -1 +1 @@
d60f3dbc38e60e11
3a4db10fc28b7a86