Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ensure we sort variants alphabetically by root
For incremental rebuilds we don't know all the used variants upfront,
which means that we can't sort them upfront either (what we used to do).

This code now allows us to sort the variants deterministically when
sorting the variants themselves instead of relying on the fact that they
used to be sorted before.

The sort itself could change slightly compared to the previous
implementation (especially when you used stacked variants in your
candidates), but it will still be deterministic.
  • Loading branch information
RobinMalfait committed Mar 11, 2024
commit 9b4995e0c8fc4067104203da306d3cc61392f8a5
4 changes: 2 additions & 2 deletions packages/tailwindcss/src/variants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1116,13 +1116,13 @@ test('min, max and unprefixed breakpoints', () => {
}

@media (width >= 1024px) {
.min-lg\\:flex {
.lg\\:flex {
display: flex;
}
}

@media (width >= 1024px) {
.lg\\:flex {
.min-lg\\:flex {
display: flex;
}
}"
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class Variants {
let compareFn = this.compareFns.get(aOrder)
if (compareFn === undefined) return 0

return compareFn(a, z)
return compareFn(a, z) || a.root.localeCompare(z.root)
}

keys() {
Expand Down