rule_order: canonicalise layer declarations to one normal form - #1275
Merged
Merged
Conversation
Two sheets that establish the same layer order in the same places project to two different canonical strings, because the optimizer folds an empty layer block into a trailing declaration while the pin logic splits a leading multi-name statement. The canonical projection then reports the two render-equal sheets as a difference; Tailwind's preflight, whose layers are declared in one statement, reads apart from tw's block-by-block sheet. The projection is a canonical form, so it must be confluent: one output per class of sheets that render alike. Read each block as runs separated by a barrier, a statement that is not a layer itself but declares a layer below it, such as an @media holding an @layer or an @import with a layer, whose contribution depends on its condition. Within a run, write every layer name the run introduces, each a.b path expanded to a and a.b, once as one `@layer <names>;` statement at the run's first name-bearing construct, drop the run's other declarations and empty blocks, and put its style-only blocks in rank order. The order is unchanged and nothing crosses a barrier. The fuzz suite pins the two properties: respellings of one order converge, and projecting the projection changes nothing.
samoht
force-pushed
the
layer-canonical
branch
from
September 19, 2026 19:42
24a1786 to
6b1e893
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The canonical projection was not confluent for layer declarations: Tailwind's preflight, whose layers are declared in one
@layer a, b;statement, read apart from tw's block-by-block sheet though the two render the same. It now writes one@layer <names>;statement per conditional-free run, eacha.bpath expanded toathena.b, and puts the run's style-only blocks in rank order. Nothing is hoisted across a conditional group that declares a layer. A fuzz suite pins convergence and idempotence, and aCss_comparecase pins the preflight shape.