Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/bundler/options.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,9 @@ pub const ESMConditions = struct {
var require_condition_map = ConditionsMap.init(allocator);
var style_condition_map = ConditionsMap.init(allocator);

try default_condition_amp.ensureTotalCapacity(defaults.len + 2 + if (allow_addons) 1 else 0 + conditions.len);
try import_condition_map.ensureTotalCapacity(defaults.len + 2 + if (allow_addons) 1 else 0 + conditions.len);
try require_condition_map.ensureTotalCapacity(defaults.len + 2 + if (allow_addons) 1 else 0 + conditions.len);
try default_condition_amp.ensureTotalCapacity(defaults.len + 2 + @intFromBool(allow_addons) + conditions.len);
try import_condition_map.ensureTotalCapacity(defaults.len + 2 + @intFromBool(allow_addons) + conditions.len);
try require_condition_map.ensureTotalCapacity(defaults.len + 2 + @intFromBool(allow_addons) + conditions.len);
Comment thread
claude[bot] marked this conversation as resolved.
try style_condition_map.ensureTotalCapacity(defaults.len + 2 + conditions.len);

import_condition_map.putAssumeCapacity("import", {});
Expand Down Expand Up @@ -1572,9 +1572,9 @@ pub fn loadersFromTransformOptions(allocator: std.mem.Allocator, _loaders: ?api.
bun.StringArrayHashMap(Loader),
allocator,
input_loaders.extensions.len +
if (target.isBun()) default_loader_ext_bun.len else 0 +
if (target == .browser) default_loader_ext_browser.len else 0 +
default_loader_ext.len,
(if (target.isBun()) default_loader_ext_bun.len else 0) +
(if (target == .browser) default_loader_ext_browser.len else 0) +
default_loader_ext.len,
input_loaders.extensions,
loader_values,
);
Expand Down
13 changes: 13 additions & 0 deletions test/bundler/bun-build-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,19 @@ identity(mod23);
expect(text).toContain(" globalThis.");
});

test.concurrent("conditions array with many entries does not crash", async () => {
const dir = tempDirWithFiles("bun-build-many-conditions", {
"entry.js": `export const a = 1;`,
});

const build = await Bun.build({
entrypoints: [join(dir, "entry.js")],
conditions: ["aa", "bb", "cc", "dd", "ee", "ff", "gg", "hh"],
});

expect(build.success).toBe(true);
});

describe.concurrent("sourcemap boolean values", () => {
test("sourcemap: true should work (boolean)", async () => {
const dir = tempDirWithFiles("sourcemap-true-boolean", {
Expand Down
Loading