Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
davesnx
force-pushed
the
parser-selector-gaps
branch
from
September 22, 2026 12:46
9adb516 to
751b12d
Compare
davesnx
force-pushed
the
generate-statement-at-rules
branch
2 times, most recently
from
September 22, 2026 13:32
8475cec to
e5ec9b6
Compare
davesnx
force-pushed
the
parser-selector-gaps
branch
2 times, most recently
from
September 23, 2026 06:11
c69888c to
87f2f2e
Compare
davesnx
force-pushed
the
generate-statement-at-rules
branch
from
September 23, 2026 06:11
e5ec9b6 to
6274a2a
Compare
Browsers honor `@import`, `@namespace` and statement-form `@layer a, b;`
only when they precede every other rule, and dependency order routinely
places the module that emits one after modules with plain style rules.
After dedup, `run` partitions the rendered rules into statement at-rules
(start with `@`, contain no `{`) and everything else, and writes the
statements first in both the flat and the `--layers` output, ahead of the
`@property`/`@keyframes` registrations and the aggregator's own `@layer`
statement.
`@charset` is dropped with a warning naming the input file instead of
hoisted: the generated file always opens with a comment, so `@charset`
can never be its first bytes, and the output is UTF-8 regardless (#581).
Hoisting every @-rule without a `{` also moved statement-form `@layer a, b;`,
which changes layer order (first occurrence wins), let `@namespace` precede
`@import` against Cascade 5, and misread `@import url("a{b.css");` as a
block rule. Classify by prefix and trailing `;`, emit the `@import` block
first and the `@namespace` block second, each keeping its relative order,
and leave `@layer` statements where ordering placed them. Docs and CHANGES
follow.
davesnx
force-pushed
the
parser-selector-gaps
branch
from
September 23, 2026 06:39
87f2f2e to
957d121
Compare
davesnx
force-pushed
the
generate-statement-at-rules
branch
from
September 23, 2026 06:39
6274a2a to
86e02dc
Compare
davesnx
added a commit
that referenced
this pull request
Sep 23, 2026
Browsers only honor `@import` and `@namespace` when they precede every other rule, and CSS Cascade 5 requires every `@import` to precede every `@namespace`, while dependency order routinely places a module that emits one after modules with plain style rules. styled-ppx.generate now hoists the `@import` block, then the `@namespace` block, each keeping its relative order. Rules are classified by their `@import`/`@namespace` prefix and trailing `;`, not by the absence of `{`, so `@import url("a{b.css");` is not mistaken for a block rule. Statement-form `@layer a, b;` stays where ordering placed it, because layer order is first occurrence and moving it would reorder a library's cascade layers. `@charset` is dropped with a warning naming the input file: the generated file always opens with its own comment.
Closes #581. Squashes the three commits of PR #614 (772faa2, d814af3, 86e02dc) onto this branch.
davesnx
added a commit
that referenced
this pull request
Sep 23, 2026
Browsers only honor `@import` and `@namespace` when they precede every other rule, and CSS Cascade 5 requires every `@import` to precede every `@namespace`, while dependency order routinely places a module that emits one after modules with plain style rules. styled-ppx.generate now hoists the `@import` block, then the `@namespace` block, each keeping its relative order. Rules are classified by their `@import`/`@namespace` prefix and trailing `;`, not by the absence of `{`, so `@import url("a{b.css");` is not mistaken for a block rule. Statement-form `@layer a, b;` stays where ordering placed it, because layer order is first occurrence and moving it would reorder a library's cascade layers. `@charset` is dropped with a warning naming the input file: the generated file always opens with its own comment.
Closes #581. Squashes the three commits of PR #614 (772faa2, d814af3, 86e02dc) onto this branch.
davesnx
added a commit
that referenced
this pull request
Sep 23, 2026
Browsers only honor `@import` and `@namespace` when they precede every other rule, and CSS Cascade 5 requires every `@import` to precede every `@namespace`, while dependency order routinely places a module that emits one after modules with plain style rules. styled-ppx.generate now hoists the `@import` block, then the `@namespace` block, each keeping its relative order. Rules are classified by their `@import`/`@namespace` prefix and trailing `;`, not by the absence of `{`, so `@import url("a{b.css");` is not mistaken for a block rule. Statement-form `@layer a, b;` stays where ordering placed it, because layer order is first occurrence and moving it would reorder a library's cascade layers. `@charset` is dropped with a warning naming the input file: the generated file always opens with its own comment.
Closes #581. Squashes the three commits of PR #614 (772faa2, d814af3, 86e02dc) onto this branch.
davesnx
added a commit
that referenced
this pull request
Sep 24, 2026
Browsers only honor `@import` and `@namespace` when they precede every other rule, and CSS Cascade 5 requires every `@import` to precede every `@namespace`, while dependency order routinely places a module that emits one after modules with plain style rules. styled-ppx.generate now hoists the `@import` block, then the `@namespace` block, each keeping its relative order. Rules are classified by their `@import`/`@namespace` prefix and trailing `;`, not by the absence of `{`, so `@import url("a{b.css");` is not mistaken for a block rule. Statement-form `@layer a, b;` stays where ordering placed it, because layer order is first occurrence and moving it would reorder a library's cascade layers. `@charset` is dropped with a warning naming the input file: the generated file always opens with its own comment.
Closes #581. Squashes the three commits of PR #614 (772faa2, d814af3, 86e02dc) onto this branch.
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.
Browsers honor
@import,@namespaceand statement-form@layer a, b;only when they precede every other rule, andstyled-ppx.generatepreserved module order, so a statement emitted by a module ordered late landed mid-stylesheet where browsers ignore it (#581). After dedup,runnow partitions the rendered rules into statement at-rules and everything else and writes the statements first, in their existing relative order. A rule is a statement at-rule when it starts with@and contains no{;Renderkeeps block rules on one line too, so the brace is what tells@media (...) { ... }apart. Under--layersthe statements come before the@property/@keyframesregistrations, the aggregator's own@layer <libraries>;statement, and every wrapped block. Dedup is unchanged.@charsetis dropped with a warning naming the input file instead of hoisted: the generated file always opens with a comment, so@charsetcan never be its first bytes, and the output is UTF-8 regardless of what a module declares.documents/css-extraction.mdrecords both decisions.Evidence at 091beef:
packages/generate/test/statement-at-rules.t: two modules with no dependency edge, the statement module ordered second; covers the flat output and--layers. Red before the change:.a{color:red;}came first,@charsetleaked through without a warning.packages/ppx/test/css-support/at-rule-statement-forms.t: expectation updated for the@charsetdrop and its warning; no reordering in that single-module case.make format-check,make build,make test: all exit 0.Risk: two-way door. Output changes only for stylesheets that contain statement at-rules or
@charset; a revert restores module order for them.