Fix crash in Bun.build() with many conditions - #30557
Closed
robobun wants to merge 1 commit into
Closed
Claude / Claude Code Review
completed
May 12, 2026 in 9m 1s
Code review found 2 potential issues
Found 4 candidates, confirmed 2. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 0 |
| 🟡 Nit | 1 |
| 🟣 Pre-existing | 1 |
| Severity | File:Line | Issue |
|---|---|---|
| 🟡 Nit | src/bundler/options.zig:1090 |
Same if-else precedence pattern remains in loadersFromTransformOptions |
| 🟣 Pre-existing | src/bundler/options.zig:1094 |
style_condition_map reserves capacity for user conditions but init() never inserts them |
Annotations
Check warning on line 1090 in src/bundler/options.zig
claude / Claude Code Review
Same if-else precedence pattern remains in loadersFromTransformOptions
nit (pre-existing): the same `if (cond) a else 0 + ...` precedence pattern this PR fixes also exists in `loadersFromTransformOptions` (~line 1575): `input_loaders.extensions.len + if (target.isBun()) default_loader_ext_bun.len else 0 + if (target == .browser) ... else 0 + default_loader_ext.len`. It doesn't crash there because the subsequent inserts use `getOrPutValue` (which grows) rather than `putAssumeCapacity`, so the only effect is an unnecessary reallocation — but since this PR is specific
Check notice on line 1094 in src/bundler/options.zig
claude / Claude Code Review
style_condition_map reserves capacity for user conditions but init() never inserts them
Pre-existing, not introduced here, but since you're touching this exact block: `style_condition_map` reserves capacity for `conditions.len` on the line right below, yet the `for (conditions)` loop a few lines down only inserts into import/require/default — never style. Meanwhile `ESMConditions.appendSlice` *does* add to `self.style`, so whether a user condition applies to CSS `@import` package-exports resolution depends on which codepath populated the struct. Probably worth a follow-up (either a
Loading