aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/options.zig3
-rw-r--r--src/runtime.footer.js4
-rw-r--r--src/runtime.js29
-rw-r--r--src/runtime.version2
-rw-r--r--src/runtime.zig17
5 files changed, 51 insertions, 4 deletions
diff --git a/src/options.zig b/src/options.zig
index 83901403c..144b476e8 100644
--- a/src/options.zig
+++ b/src/options.zig
@@ -466,6 +466,7 @@ pub const Platform = enum {
.default = @as(string, "default"),
.bun = @as(string, "bun"),
.bun_macro = @as(string, "bun_macro"),
+ .module = @as(string, "module"), // used in tslib
};
pub const DefaultConditions: std.EnumArray(Platform, []const string) = brk: {
@@ -498,12 +499,14 @@ pub const Platform = enum {
// which will crash or fail to be bundled when targeting the browser.
var listc = [_]string{
default_conditions_strings.browser,
+ default_conditions_strings.module,
};
array.set(Platform.browser, &listc);
array.set(
Platform.bun,
&[_]string{
default_conditions_strings.bun,
+ default_conditions_strings.module,
default_conditions_strings.browser,
},
);
diff --git a/src/runtime.footer.js b/src/runtime.footer.js
index 0394a6624..5f2773159 100644
--- a/src/runtime.footer.js
+++ b/src/runtime.footer.js
@@ -16,4 +16,8 @@ export var __export = BUN_RUNTIME.__export;
export var __reExport = BUN_RUNTIME.__reExport;
export var __cJS2eSM = BUN_RUNTIME.__cJS2eSM;
export var regeneratorRuntime = BUN_RUNTIME.regeneratorRuntime;
+export var __exportValue = BUN_RUNTIME.__exportValue;
+export var __exportDefault = BUN_RUNTIME.__exportDefault;
+export var $$bun_runtime_json_parse = JSON.parse;
+
globalThis.require ||= BUN_RUNTIME.__require;
diff --git a/src/runtime.js b/src/runtime.js
index 98a716527..6e8822767 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -155,10 +155,35 @@ export var __name = (target, name) => {
return target;
};
-// Used to implement ES6 exports to CommonJS
+// ESM export -> CJS export
+// except, writable incase something re-exports
export var __export = (target, all) => {
for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
+ __defProp(target, name, {
+ get: all[name],
+ enumerable: true,
+ configurable: true,
+ set: (newValue) => (all[name] = () => newValue),
+ });
+};
+
+export var __exportValue = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, {
+ get: () => all[name],
+ set: (newValue) => (all[name] = newValue),
+ enumerable: true,
+ configurable: true,
+ });
+};
+
+export var __exportDefault = (target, value) => {
+ __defProp(target, "default", {
+ get: () => value,
+ set: (newValue) => (value = newValue),
+ enumerable: true,
+ configurable: true,
+ });
};
export var __reExport = (target, module, desc) => {
diff --git a/src/runtime.version b/src/runtime.version
index 8e6c33eff..f5f0047b9 100644
--- a/src/runtime.version
+++ b/src/runtime.version
@@ -1 +1 @@
-3a4db10fc28b7a86 \ No newline at end of file
+c92310420c760f74 \ No newline at end of file
diff --git a/src/runtime.zig b/src/runtime.zig
index 046e1a863..77a0430d1 100644
--- a/src/runtime.zig
+++ b/src/runtime.zig
@@ -231,6 +231,8 @@ pub const Runtime = struct {
__HMRModule: ?GeneratedSymbol = null,
__HMRClient: ?GeneratedSymbol = null,
__FastRefreshModule: ?GeneratedSymbol = null,
+ __exportValue: ?GeneratedSymbol = null,
+ __exportDefault: ?GeneratedSymbol = null,
pub const all = [_][]const u8{
"__name",
@@ -245,6 +247,8 @@ pub const Runtime = struct {
"__HMRModule",
"__HMRClient",
"__FastRefreshModule",
+ "__exportValue",
+ "__exportDefault",
};
pub const Name = "<RUNTIME";
@@ -323,7 +327,16 @@ pub const Runtime = struct {
return Entry{ .key = 11, .value = val.ref };
}
},
-
+ 12 => {
+ if (@field(this.runtime_imports, all[12])) |val| {
+ return Entry{ .key = 12, .value = val.ref };
+ }
+ },
+ 13 => {
+ if (@field(this.runtime_imports, all[13])) |val| {
+ return Entry{ .key = 13, .value = val.ref };
+ }
+ },
else => {
return null;
},
@@ -380,6 +393,8 @@ pub const Runtime = struct {
9 => (@field(imports, all[9]) orelse return null).ref,
10 => (@field(imports, all[10]) orelse return null).ref,
11 => (@field(imports, all[11]) orelse return null).ref,
+ 12 => (@field(imports, all[12]) orelse return null).ref,
+ 13 => (@field(imports, all[13]) orelse return null).ref,
else => null,
};
}