Skip to content

Add failing tests: @import stylesheets must break concat groups - #99

Merged
mreishus merged 1 commit into
mainfrom
reish20260203/show-imports-not-force-to-beginning-of-group
Feb 3, 2026
Merged

mreishus merged 1 commit into
mainfrom
reish20260203/show-imports-not-force-to-beginning-of-group

Conversation

@mreishus

@mreishus mreishus commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

Adds tests that show a cascade ordering bug when stylesheets contain @import rules.

The problem:

The concat service hoists all @import statements to the top of combined output (which is required for valid CSS). But if a stylesheet with @import is concatenated after other stylesheets, its imports jump ahead of rules that should have come first, breaking cascade order.

For example, if you enqueue in order a.css -> b.css (has @import) -> c.css:

  • Current behavior: [a, b, c] -> @import from b appears before a's rules
  • Correct behavior: [a], [b, c] -> b starts a new group, so the hoist stays in order

What the tests cover:

  1. test_import_stylesheet_breaks_concat_run_before_it

    • Enqueue: a (plain) -> b (@import) -> c (plain)
    • Expected groups: [a], [b, c]
  2. test_import_stylesheet_only_allowed_first_in_group

    • Enqueue: a (@import) -> b (plain) -> c (@import) -> d (plain)
    • Expected groups: [a, b], [c, d]

Both tests fail on trunk because grouping currently ignores @import presence.

@mreishus

mreishus commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

Note that the tests have the @group css-order-bug tag, so they still appear green in github. You have to click inside to see:

Screenshot 2026-02-03 at 10 59 13 AM

Or run docker compose up --build --abort-on-container-exit --exit-code-from tests directly.

@mreishus
mreishus merged commit 51008f6 into main Feb 3, 2026
3 checks passed
@mreishus
mreishus deleted the reish20260203/show-imports-not-force-to-beginning-of-group branch February 3, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant