Convert generated css compat table to a data table#31999
Conversation
|
Updated 2:13 PM PT - Jun 12th, 2026
❌ @robobun, your commit 35b133a has 3 failures in
🧪 To try this PR locally: bunx bun-pr 31999That installs a local version of the PR into your bun-31999 --bun |
|
@robobun adopt |
WalkthroughThis PR adds default rejecting implementations to CSS parser traits, simplifies many rule parser implementations to use those defaults, extends browser mapping data (adds webview_ios), generates a Rust compat module from the compatibility table, and removes an inline URL-to-css shim in custom properties. ChangesParser trait defaults and implementation cleanup
CSS browser compatibility and Rust code generation
Custom properties URL serialization refactoring
Tests and minor fixes
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Adopted and ready for review. The open question in the description is resolved: build-prefixes.js now emits the table-form compat.rs (verified byte-identical when driven with the same dataset it was generated from), and regression tests pin the compat table boundaries and the at-rule parser defaults. CI on the merged head (build 61622): all CSS tests pass on every lane. After retries the single remaining red is darwin 14 aarch64, where two timing-sensitive fetch tests flaked (fetch-abort-slow-connect, a 50ms AbortSignal race, and fetch-leak, an RSS-threshold probe); unrelated to this diff. |
|
@robobun does anything get faster because of this table? |
|
Runtime: no. Binary size: yes. The CI size check on this build compares against main exactly at the merge point (build 61606 = 09703da), so the delta is this diff alone: -16 KB darwin-x64, -32 KB linux-x64 and x64-baseline, -48 KB darwin-aarch64, -64 KB linux-aarch64. The bigger aarch64 savings fit deleting ~5.2k lines of compare-and-branch codegen (fixed-width instructions make branchy code larger there), replaced by a 7.6 KB static table. Compile time of bun_css: I timed old vs new on this container (3 runs each, dev and release) and the difference is within run-to-run noise, so no claim there. So the honest answer is smaller, not faster; the motivation remains the -5.2k lines and build-prefixes.js being able to regenerate the file. |
What this does
Split from #31912 (whole-repo simplification pass, closed in favor of module-scoped splits). Moves and removes code with zero intended behavior change, and makes
src/css/compat.rsregenerable.src/css/compat.rs: replaces the generated 5.4k-linematch(one arm of version checks per feature) with a per-feature minimum-version table consumed by genericis_compatible/is_partially_compatiblechecks.src/css/css_parser.rs: givesAtRuleParserandQualifiedRuleParserdefault method implementations that reject the rule, and deletes the copy-pasted reject-all impls fromdeclaration.rs,font_face.rs,font_palette_values.rs,keyframes.rs,page.rs,property.rs.src/css/properties/custom.rs: drops the inlinedurl_to_cssshim and callsUrl::to_cssdirectly (now un-gated invalues/url.rsand already used byfont_face.rs,image.rs,syntax.rs). The shared fn checksflags.is_internalexactly like the Zig reference; the shim had deviated totag.is_internal().src/css/build-prefixes.js: now emits the table-formcompat.rsalongsidecompat.zig, resolving the regenerability question this PR originally left open. Also restores theallBrowsersdefinition that remove all usingnamespace in css #19067 deleted while the script still references it (the script could not run at all without it), and maps BCD'swebview_iosagent to null the same wayoculusalready is (newer BCD data otherwise crashes the script).Feature::FontSizeXxxLarge, matching the existingAbsoluteFontSize::XxxLargeinproperties/font.rs); the generator's name derivation collapses single-letter segment runs accordingly.Verification
generateCompatRsthe data parsed out of the checked-incompat.zig(generated from the same original dataset); the output is byte-identical to the checked-incompat.rs, so the file is exactly what regeneration produces.autoprefixer@10.4.20,caniuse-lite@1.0.30001663,@mdn/browser-compat-data@5.6.0): completes, output is rustfmt-idempotent, and differs from the checked-in file only in 24 rows of data values that moved between dataset snapshots. Running against current@mdn/browser-compat-data8.x additionally needs schema adaptations (css.types.image.gradientmoved, etc.); that predates this PR and is left alone.cargo check -p bun_cssclean.bun bd test test/js/bun/css/andbun bd test test/bundler/css/pass, except thecss-fuzzandfuzz ansi256timeouts, which fail identically at the merge base under a debug+ASAN build (pre-existing debug slowness, verified by running them on main).No test changes: this is a behavior-preserving refactor, and the existing CSS suites (2300+ tests) are the regression net.
Tests
test/js/bun/css/css.test.tsgains two blocks pinning the refactored surfaces:browser compat feature table: for three features spread across the table (MediaRangeSyntax,HexAlphaColors,FontFamilySystemUi), one target just below the minimum browser version (must lower) and one at the minimum (must preserve), driven throughcssInternalstargets. These catch table row/enum misalignment or wrong minimums.at-rule and qualified-rule rejection defaults: unknown at-rules and qualified rules inside@font-face,@keyframes,@font-palette-values,@property, and style attributes hit the new trait defaults; tests pin the recovery output and theUnknown at-rule @boguserror message.Since this PR is a behavior-preserving refactor, these tests pass both before and after by construction: a test that failed on the merge base would contradict the equivalence this PR claims. They were run against both the merge base and this branch to confirm identical output, and they pin the refactored surfaces so any future regression in the table data, row ordering, or the trait defaults fails loudly.