diff options
author | 2021-09-09 23:33:34 -0700 | |
---|---|---|
committer | 2021-09-09 23:33:34 -0700 | |
commit | fc907e2f81698d89502fb2ee0375e6d98a492c13 (patch) | |
tree | e775c2479b334ec901f61b5c0ccfab0102ff679e /src/runtime.js | |
parent | 8a02ad48a5eb1319c1bf3e9eb97e013924db875f (diff) | |
download | bun-fc907e2f81698d89502fb2ee0375e6d98a492c13.tar.gz bun-fc907e2f81698d89502fb2ee0375e6d98a492c13.tar.zst bun-fc907e2f81698d89502fb2ee0375e6d98a492c13.zip |
currentjarred/fetch-experiment
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/runtime.js b/src/runtime.js index bcfd4c3fb..98cea8b8a 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -37,6 +37,7 @@ export var __toModule = (module) => { ); }; +var tagSymbol = Symbol("CommonJSTransformed"); export var __commonJS = (cb, name) => { var mod = {}; var has_run = false; @@ -59,21 +60,8 @@ export var __commonJS = (cb, name) => { if ( kind === "object" && "default" in mod.exports && - Object.keys(mod.exports).len === 1 - ) { - 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 === "object" && - "default" in mod.exports && - Object.keys(mod.exports).len === 1 + !mod.exports[tagSymbol] && + Object.keys(mod.exports).length === 1 ) { mod.exports = mod.exports.default; Object.defineProperty(mod.exports, "default", { @@ -101,6 +89,14 @@ export var __commonJS = (cb, name) => { }); } + if (kind === "object" && !mod.exports[tagSymbol]) { + Object.defineProperty(mod.exports, tagSymbol, { + value: true, + enumerable: false, + configurable: false, + }); + } + return mod.exports; }, }[`require(${name})`]; |