aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-23 17:34:54 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-23 17:34:54 -0700
commit2177dda2425c2ab556fea3e7b2cf13dccd847893 (patch)
tree71e768627b5e1186a1142433e8ec16789c48ed55 /src/runtime.js
parent0585c86390d20e330ea8a7a8ed74eb079064a8f5 (diff)
downloadbun-2177dda2425c2ab556fea3e7b2cf13dccd847893.tar.gz
bun-2177dda2425c2ab556fea3e7b2cf13dccd847893.tar.zst
bun-2177dda2425c2ab556fea3e7b2cf13dccd847893.zip
Fix bug when multiple-levels of nested exports when bundled have a boolean .default value
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 033e2c9d8..98a716527 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -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") &&