css: keep '/' and '*' delims separated when minifying token lists - #33683
Conversation
When minifying a custom property (or any unparsed value) whose token list contains a '/' delim followed by a '*' delim, the two were printed adjacently as '/*', opening a comment that swallows the rest of the stylesheet. TokenList::to_css already computes ws_before for '/' and '*' to avoid this, but Printer::delim routes that through Printer::whitespace, which writes nothing when minifying, and the arm then set has_whitespace = true regardless, so the following delim's guard was skipped too. Emit a real space after a '/' or '*' delim in minify mode when the next token is the other half of the pair. Lone '/' or '*' delims (e.g. '--a: 16 / 9') still minify without extra whitespace, and non-minified output is unchanged.
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
|
Updated 11:05 AM PT - Jul 7th, 2026
❌ @robobun, your commit 540a493 has some failures in 🧪 To try this PR locally: bunx bun-pr 33683That installs a local version of the PR into your bun-33683 --bun |
Repro
The
/*afterxopens a comment. Reparsing Bun's own output drops.k { color: red }(and everything after it) entirely. esbuild preserves the value byte-for-byte.Cause
TokenList::to_css(src/css/properties/custom.rs) already computesws_before = !has_whitespace && (d == '/' || d == '*')precisely to prevent this, butPrinter::delimroutesws_beforethroughPrinter::whitespace(), which writes nothing when minifying. The arm then setshas_whitespace = trueregardless of whether a byte was actually written, so the following*'s guard is skipped too. Adjacent/and*delims collapse to/*.The same applies to any unparsed property value (not just
--custom) and to token-list arguments inside functions.Fix
After printing a
/or*delim in minify mode, peek at the next token: if it's the other half of the pair, emit a real space viawrite_char. This is precise: a lone/or*(e.g.--a: 16 / 9) still minifies to16/9with no extra bytes, and non-minified output is unchanged.--a: x / * yx/*yx/ *y--a: x * / yx*/yx* /y--a: 16 / 916/916/9--a: x / yx/yx/y--a: x / / yx//yx//yVerification
New
minify_testcases intest/js/bun/css/css.test.tscover/then*,*then/, a chain/ * / *, unknown properties, function arguments, the unchanged single-delim cases, and the non-minified round-trip. They fail on the current release (x/*y) and pass with the fix. Fullcss.test.ts(1129 tests),test/js/bun/css/doesnt_crash.test.ts(61 tests), andtest/bundler/css/(168 tests) pass.