aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-15 21:30:12 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-15 21:30:12 -0700
commit472589aa14822a903229571c8b8c3fc3c75fbb38 (patch)
treea75f66ac6c5faa3dcdb2963ecb9fd4c65eb68ace /src/runtime.js
parentba9825eca91993fce2032cd69cea3c808f15dc46 (diff)
downloadbun-472589aa14822a903229571c8b8c3fc3c75fbb38.tar.gz
bun-472589aa14822a903229571c8b8c3fc3c75fbb38.tar.zst
bun-472589aa14822a903229571c8b8c3fc3c75fbb38.zip
Fix require bug in runtime.js
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js39
1 files changed, 9 insertions, 30 deletions
diff --git a/src/runtime.js b/src/runtime.js
index e2fc4e681..033e2c9d8 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -121,39 +121,18 @@ export var __BUN_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
// );
export var __require = (namespace) => {
- if (typeof namespace === "function" && namespace[cjsRequireSymbol])
+ const namespaceType = typeof namespace;
+ if (namespaceType === "function" && namespace[cjsRequireSymbol])
return namespace();
+ if (
+ namespaceType === "object" &&
+ "default" in namespace &&
+ namespace.default[cjsRequireSymbol]
+ )
+ return namespace.default();
+
return namespace;
- // // is it an ESM module record?
- // if (namespaceType === "object") return namespace;
- // // is it a CommonJS module?
-
- // // i have no idea what it is so i'm just going to try stuff and pray
- // var entry = require_cache.get(namespace);
- // if (typeof entry !== "undefined") {
- // return entry;
- // }
-
- // var target =
- // Object.prototype.hasOwnProperty.call(namespace, "default") &&
- // Object.keys(namespace).length === 1
- // ? namespace["default"]
- // : namespace;
-
- // if (typeof target !== "function") {
- // throw new __BUN_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.RequireFailedError(
- // `Couldn't find module "${
- // typeof namespace === "string"
- // ? namespace
- // : namespace.name || namespace.displayName || namespace.toString()
- // }"`
- // );
- // }
-
- // var exports = target();
- // require_cache.set(namespace, exports);
- // return exports;
};
export var $$m = __commonJS;