Repository navigation
Commit ab902ff
fix(css): order a joined seam's list, and gather a layer block too big to assemble (#22224)
* fix(css): order the list a joined at-rule's seam leaves
Joining two at-rule blocks with one prelude joins the pair meeting at the
seam, and `_joinRuleEntries` concatenates the two preludes rather than
ordering them — every other join settles its list afterwards, this one
never did. So `@media print{.b{x:1}}@media print{.a{x:1}}` printed `.b,.a`
where a second pass writes `.a,.b`. Ordered once per join, so a run stays
linear. Every at-rule whose block holds rules reaches it.
* fix(css): gather a named layer block too big to assemble
A named `@layer` block past `_STREAM_MIN_NODES` streams its body, so its text
is out before it closes and the parent's gather, which reads a body whole,
never sees it: `@layer u{@layer a{}@layer a{<4096 rules>}}` wrote two blocks
of one layer where a second pass wrote one. Hold a block whose layer a
sibling already opened, read off the source, so it stays assembled and
`_mergeNamedLayerBlocks` takes it. Only that block is materialized.
* test(css): cover both fixes end to end in config cases
The unit tests call the printer; these run the two through a build, so the
seam a joined at-rule leaves and the layer a held block gathers into are
read off the emitted stylesheet. Each asserts the output is what a second
pass writes. The gather is only reached by a block big enough to stream, so
its filler is generated by a loader rather than checked in.
* fix(css): read a layer name past a comment, and take out a repeated selector
The name a held block is matched on is read off the source, where a comment
stands wherever a space may — `@layer /*c*/ a{` read as a name of its own,
so the block streamed and the gather lost it. One is taken out rather than
spelled, the name carrying no whitespace itself, and only where the prelude
holds one. Ordering the seam's list also reads out a selector both sides
carry, which the join wrote twice.
* perf(css): settle a joined block's seams where its run ends
The seam ordering runs inside `_joinRuleEntries`, so a run of joins orders
the list it is still growing once per join — quadratic in the length of the
run. The deep-nesting printer benchmark pays 335 ms -> 479 ms for it on
CodSpeed, and 19 ms -> 34 ms here on the same fixture.
A seam now concatenates like every other join and says so (`unordered`), and
the run that grew it settles it once where it ends, which is what every other
join already does — `_mergeAdjacentRules` through `finish()`, the distant
merges through `_orderDistantLists`. `_settleJoinedSeams` reads only the
children carrying a seam and writes the block's text again only where one
actually moved, so a block that grew none costs a walk of its children.
The gathers and distant merges end a run of their own, so each settles there:
the streamed layer fold, `_gatherDistantAtRule`, `_mergeNamedLayerBlocks`,
`_mergeDistantAtRule`, and the fold a finished run offers the rule before it.
Output is unchanged. Byte-identical over the 1184 stylesheets the test tree
carries and 4000 generated sheets, and the deep-nesting fixture is back to
19.3 ms against a 19.2 ms baseline.
Tests: the seam a gather leaves, one a run of gathers grows, the distant
at-rule seams, and a gathered block big enough to stream — the paths that
reach a seam without a join run behind them.
Co-authored-by: aryanraj45 <[email protected]>
* test(css): cover the seam a top-level layer gather leaves
The one settle site the suite did not reach: a layer the sheet itself holds,
where the block a later one folds into is a rule already written out.
Co-authored-by: aryanraj45 <[email protected]>
* chore(changeset): fold the two entries into one
One changeset per pull request: the seam order and the layer gather are the
same bug family, so they read as one line in the changelog.
Co-authored-by: aryanraj45 <[email protected]>
* chore(changeset): keep the entry within the length the guide asks for
Co-authored-by: aryanraj45 <[email protected]>
---------
Co-authored-by: aryanraj45 <[email protected]>1 parent e7911a5 commit ab902ff
14 files changed
Lines changed: 590 additions & 41 deletions
File tree
- .changeset
- lib/css
- test
- configCases/css
- minify-at-rule-seam-order
- __snapshots__
- minify-layer-gather-large-block
- unitCases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments