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.
This PR further improves the canonicalization of units in Tailwind CSS to increase the amount of similar candidates that can be converted to their canonical form.
This also introduces a
rem
option to thecanonicalizeCandidates([…], { rem: 16 })
. If this is passed with a pixel value, thenrem
units will be converted topx
values. This is not enabled by default while running upgrades, but this can be used (e.g.: in intellisense).This allows us to migrate
mt-[16px]
tomt-4
(assuming--spacing: 0.25rem
is defined). Rem to px value migrations are not safe by default (because it depends on the root font size), but Intellisense can use them to provide a suggestion because in most cases that is what you want.Internally this required a refactor because we now need the
rem
value as well. This introduced aSignatureOptions
interface to make sure that we have a single stable object that can be passed around and that all the caches exist perSignatureOptions
object. This means that you can callcanonicalizeCandidates
with differentrem
values without influencing other options.As a user, you don't have to worry about making this second object stable, that will happen internally already.
Usage example:
Test plan
rem
valuerem
value or a different value after the previous calls don't touch shared caches.