Skip to content

CSS minifier drops one of two adjacent :where() rules that hold only custom properties (1.4.2 regression) #44704

Closed

Description

@cntlsn

What version of Bun is running?

1.4.2 (1.3.11 is not affected)

What platform is your computer?

Darwin 25.6.0 arm64 (also seen in a hosted build that uses 1.4.2)

What steps can reproduce the bug?

t.css:

:where(.x){--a:1}:where(.x){--b:2}

index.html:

<link rel="stylesheet" href="./t.css"><p>x</p>
bun build ./index.html --outdir out --minify
cat out/*.css

What is the expected behavior?

Both custom properties survive, merged or not:

:where(.x){--a:1;--b:2}

This is what 1.3.11 produces (it keeps both rules), and what 1.4.2 produces for plain selectors.

What do you see instead?

:where(.x){--b:2}

--a is gone.

More cases with 1.4.2 --minify:

Input Output
.x{--a:1}.x{--b:2} .x{--a:1;--b:2} ✅
:root{--a:1}:root{--b:2} :root{--a:1;--b:2} ✅
:is(.x){--a:1}:is(.x){--b:2} .x{--a:1;--b:2} ✅
:where(.x){color:red}:where(.x){margin:0} unchanged ✅
:where(.x){--a:1;color:red}:where(.x){--b:2} unchanged ✅
:where(.x){--a:1}:where(.x){--b:2} :where(.x){--b:2} ❌
:where(.x) .y{--a:1}:where(.x) .y{--b:2} :where(.x) .y{--b:2} ❌

So it needs two adjacent rules with the same selector containing :where(), where both rules hold only custom properties. It looks as if the rules are treated as duplicates and the earlier one is dropped, without comparing the property names.

Additional information

Hit in practice when scoping a third-party stylesheet with :where(.scope): its consecutive :root{…} variable blocks became :where(.scope){…} pairs and one was lost in production builds only. Possibly related to #40364 (:where() selector lists being split).

Activity

  1. added a commit that references this issue on Oct 27, 2026
    7942008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions