aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/runtime.js24
-rw-r--r--src/runtime.version2
2 files changed, 17 insertions, 9 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") &&
diff --git a/src/runtime.version b/src/runtime.version
index a1ae4839c..8e6c33eff 100644
--- a/src/runtime.version
+++ b/src/runtime.version
@@ -1 +1 @@
-d60f3dbc38e60e11 \ No newline at end of file
+3a4db10fc28b7a86 \ No newline at end of file