Skip to content

Discard invalid variants and utilities with modifiers #13977

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

Merged
merged 9 commits into from
Jul 10, 2024

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Jul 10, 2024

This PR discards candidates that contain modifiers for variants and utilities that don't need it.

For example, right now you can use hover/foo:flex or even flex/foo. These generate the exact same contents as hover:flex and flex respectively. However, the foo modifier isn't used but is still included in the class name, which means that this currently just generates additional unnecessary CSS.

For static utilities and static variants, we can bail early when we detect a modifier and we don't have to continue parsing the candidate. We also don't have to run the known invalid candidate through the system. (In theory if you have a lot of invalid candidates like this it will result in better performance and smaller CSS)

Some utilities and variants accept modifiers, e.g.: bg-red-500/50 or group-hover/foo. In these cases we can't discard the modifier automatically, which is why the PR is relatively big because we have to discard on a case by case basis.

Requires:

Base automatically changed from fix/discard-invalid-candidates to next July 10, 2024 08:01
@RobinMalfait RobinMalfait force-pushed the fix/discard-invalid-modifiers branch from aacb7b5 to 0a06fa6 Compare July 10, 2024 08:09
@RobinMalfait RobinMalfait force-pushed the fix/discard-invalid-modifiers branch from 6565b49 to 5d014c0 Compare July 10, 2024 13:45
@RobinMalfait RobinMalfait force-pushed the fix/discard-invalid-modifiers branch from 5d014c0 to fa3e523 Compare July 10, 2024 13:53
@RobinMalfait RobinMalfait merged commit 6c0c6a5 into next Jul 10, 2024
1 check passed
@RobinMalfait RobinMalfait deleted the fix/discard-invalid-modifiers branch July 10, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants