aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-30 22:34:17 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-30 22:34:17 -0700
commitf226f52200b9c1aaaea7bc8e3068d5f6ec978440 (patch)
tree8407b1cd50bc19fb8fffad24558f5e82d1542bd6
parentdb24a27e61364d540ababce0cd3ca6354e89dcc9 (diff)
downloadbun-f226f52200b9c1aaaea7bc8e3068d5f6ec978440.tar.gz
bun-f226f52200b9c1aaaea7bc8e3068d5f6ec978440.tar.zst
bun-f226f52200b9c1aaaea7bc8e3068d5f6ec978440.zip
Fix edgecase with cjs -> esm interop runtime code when module.exports was marked as not extensible
-rw-r--r--src/runtime.js29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 83bdff938..0c4f53930 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -12,7 +12,7 @@ export var __markAsModule = (target) =>
// lazy require to prevent loading one icon from a design system
export var $$lzy = (target, module, props) => {
for (let key in props) {
- if (!__hasOwnProp.call(target, key) && key !== "default")
+ if (!__hasOwnProp.call(target, key))
__defProp(target, key, {
get: () => module()[props[key]],
enumerable: true,
@@ -99,7 +99,8 @@ export var __commonJS = (cb, name) => {
// If it's a namespace export without .default, pretend .default is the same as mod.exports
} else if (
(kind === "function" || kind === "object") &&
- !("default" in mod.exports)
+ !("default" in mod.exports) &&
+ Object.isExtensible(mod.exports)
) {
var defaultValue = mod.exports;
Object.defineProperty(mod.exports, "default", {
@@ -114,7 +115,11 @@ export var __commonJS = (cb, name) => {
});
}
- if (kind === "object" && !mod.exports[tagSymbol]) {
+ if (
+ kind === "object" &&
+ !mod.exports[tagSymbol] &&
+ Object.isExtensible(mod.exports)
+ ) {
Object.defineProperty(mod.exports, tagSymbol, {
value: true,
enumerable: false,
@@ -131,21 +136,6 @@ export var __commonJS = (cb, name) => {
export var __cJS2eSM = __commonJS;
-var require_cache = new WeakMap();
-
-export var __BUN_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
- RequireFailedError: class {},
-};
-
-// __name(
-// __BUN_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__MODULE_LOAD_CACHE.RequireFailedError,
-// "RequireFailedError"
-// );
-// __name(
-// __BUN_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__MODULE_LOAD_CACHE.Module,
-// "Module"
-// );
-
export var __require = (namespace) => {
const namespaceType = typeof namespace;
if (namespaceType === "function" && namespace[cjsRequireSymbol])
@@ -221,5 +211,8 @@ export var __reExport = (target, module, desc) => {
if (typeof globalThis.process === "undefined") {
globalThis.process = {
env: {},
+ cwd() {
+ return "/bun-fake-dir/";
+ },
};
}