Sort class lists deterministically for Prettier plugin (#10672)
* Ensure class sorting is deterministic for Prettier * Update changelog
This commit is contained in:
parent
261a8b42cb
commit
d2a95a00a8
3 changed files with 39 additions and 4 deletions
|
|
@ -931,12 +931,19 @@ function registerPlugins(plugins, context) {
|
|||
prefix(context, 'peer'),
|
||||
]
|
||||
context.getClassOrder = function getClassOrder(classes) {
|
||||
// Sort classes so they're ordered in a deterministic manner
|
||||
let sorted = [...classes].sort((a, z) => {
|
||||
if (a === z) return 0
|
||||
if (a < z) return -1
|
||||
return 1
|
||||
})
|
||||
|
||||
// Non-util classes won't be generated, so we default them to null
|
||||
let sortedClassNames = new Map(classes.map((className) => [className, null]))
|
||||
let sortedClassNames = new Map(sorted.map((className) => [className, null]))
|
||||
|
||||
// Sort all classes in order
|
||||
// Non-tailwind classes won't be generated and will be left as `null`
|
||||
let rules = generateRules(new Set(classes), context)
|
||||
let rules = generateRules(new Set(sorted), context)
|
||||
rules = context.offsets.sort(rules)
|
||||
|
||||
let idx = BigInt(parasiteUtilities.length)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue