Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort arbitrary variants deterministically regardless of content order #10016

Merged
merged 5 commits into from Dec 8, 2022

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Dec 8, 2022

Currently arbitrary variants are non-deterministic in their sorting given multiple environments or different sets of content. For example, if you run your build on your local environment in Windows and then again in CI which is on Linux it is possible that you can get different built output and different sorting for utilities using arbitrary variants.

This change ensures that utilities using arbitrary variants are sorted in a deterministic manner (by byte, ascending). Given that arbitrary variants are registered on-demand when they are found it complicates the sorting process a bit but it's still fairly reasonable.

This should fix the problem noted here: tailwindlabs/prettier-plugin-tailwindcss#106

This didn’t actually have any negative effect because of how it was implemented. But it only happened to work right :D
@thecrypticace thecrypticace force-pushed the fix/deterministic-arbitrary-variant-sorting branch from 428f560 to 89da23f Compare December 8, 2022 04:40
We really only care that the order is _always_ the same. localeCompare is still locale dependent based on environment. This ensures it’s dependent on content only.
@thecrypticace thecrypticace merged commit cea0838 into master Dec 8, 2022
@thecrypticace thecrypticace deleted the fix/deterministic-arbitrary-variant-sorting branch December 8, 2022 14:05
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.

None yet

1 participant