aboutsummaryrefslogtreecommitdiff
path: root/src/js/builtins/Module.ts
diff options
context:
space:
mode:
authorGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-06-27 18:23:56 -0700
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-06-27 18:23:56 -0700
commitf670c0fc1866352b846f092e4f0741b51f59ec1a (patch)
tree917c87e86b4ac6dac8b02ac91619ac99f8fb0036 /src/js/builtins/Module.ts
parent09994d6067a2df1095a29619ecdbb56ae10b0974 (diff)
downloadbun-f670c0fc1866352b846f092e4f0741b51f59ec1a.tar.gz
bun-f670c0fc1866352b846f092e4f0741b51f59ec1a.tar.zst
bun-f670c0fc1866352b846f092e4f0741b51f59ec1a.zip
don't overwrite `__esModule`
Diffstat (limited to 'src/js/builtins/Module.ts')
-rw-r--r--src/js/builtins/Module.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/js/builtins/Module.ts b/src/js/builtins/Module.ts
index 6a0b70a37..0b5fcafe8 100644
--- a/src/js/builtins/Module.ts
+++ b/src/js/builtins/Module.ts
@@ -46,6 +46,8 @@ export function require(this: Module, id: string) {
const exports =
namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0
? namespace.default
+ : namespace.__esModule
+ ? namespace
: Object.create(namespace, { __esModule: { value: true } });
$requireMap.$set(id, $createCommonJSModule(id, exports, true));
return exports;
@@ -83,6 +85,8 @@ export function require(this: Module, id: string) {
// if they choose a module
namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0
? namespace.default
+ : namespace.__esModule
+ ? namespace
: Object.create(namespace, { __esModule: { value: true } }));
}
}