aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resolver/package_json.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/resolver/package_json.zig b/src/resolver/package_json.zig
index fa8603569..bff445bf2 100644
--- a/src/resolver/package_json.zig
+++ b/src/resolver/package_json.zig
@@ -55,6 +55,8 @@ pub const PackageJSON = struct {
version: string = "",
hash: u32 = 0xDEADBEEF,
+ always_bundle: []string = &.{},
+
// Present if the "browser" field is present. This field is intended to be
// used by bundlers and lets you redirect the paths of certain 3rd-party
// modules that don't work in the browser to other modules that shim that
@@ -527,6 +529,27 @@ pub const PackageJSON = struct {
}
}
+ if (json.asProperty("bun")) |bun_json| {
+ if (bun_json.expr.asProperty("alwaysBundle")) |bundle_| {
+ if (bundle_.expr.data == .e_array) {
+ var always_bundle_count: u16 = 0;
+ const array = bundle_.expr.data.e_array.items;
+ for (array) |item| {
+ always_bundle_count += @intCast(u16, @boolToInt(item.data == .e_string and item.data.e_string.utf8.len > 0));
+ }
+ package_json.always_bundle = r.allocator.alloc(string, always_bundle_count) catch unreachable;
+
+ var i: u16 = 0;
+ for (array) |item| {
+ if (!(item.data == .e_string and item.data.e_string.utf8.len > 0)) continue;
+ package_json.always_bundle[i] = item.asString(r.allocator).?;
+ i += 1;
+ }
+ // for (var i = 0; i < bundle_.expr.data.e_array.len; i++) {
+ }
+ }
+ }
+
// Read the "main" fields
for (r.opts.main_fields) |main| {
if (json.asProperty(main)) |main_json| {