kristentr#13
Merged
Merged
Conversation
## Summary - Adds `--stream` flag to `tailwindcss canonicalize` that reads candidate groups from stdin line by line and writes canonicalized results to stdout - Keeps the design system loaded across requests, making it suitable as a long-running sidecar process - Empty lines pass through, keeping request/response pairs aligned ## Motivation Non-JS tools (formatters, editor plugins, etc.) currently have no lightweight way to canonicalize Tailwind classes. The existing batch mode works for one-off use, but tools that need to canonicalize repeatedly pay the cost of loading the design system each time. With `--stream`, a tool can start `tailwindcss canonicalize --stream` once and send candidate groups over stdin as needed: ```sh $ echo -e "py-3 p-1 px-3\nmt-2 mr-2 mb-2 ml-2" | tailwindcss canonicalize --stream p-3 m-2 ``` Related discussion: #19736 --------- Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
…ale suggestions (#19809) This PR adds support for canonicalization of utilities that accept bare values and exceed the default spacing scale we use for intellisense. Right now, all utilities are behind functions, so the only way to know whether something compiles is by compiling a candidate, e.g. `w-8` and passing it to the utility functions. To help us, we use the intellisense APIs that we use for suggestions. Most utilities that accept bare values, have suggestions up until `*-96`, so `w-96 h-96` would be canonicalized to `size-96`. But the moment we exceed that, the result stays as-is. ``` → w-96 h-96 = size-96 → w-1234 h-1234 = h-1234 w-1234 ``` This PR ensures that the last scenario also gets canonicalized to `size-1234` instead of staying as `h-1234 w-1234`. ``` → w-96 h-96 = size-96 → w-1234 h-1234 = size-1234 ``` ## Test plan 1. Existing tests pass 2. Added new tests for utilities with bare values [ci-all] just to see if this additional logic doesn't cause timeouts in CI for WIndows. In my testing this doesn't have a significant impact on performance at all.
This PR fixes a bug in the canonicalization process where if a few utilities collapse into a smaller one, and the smaller one is part of the original list, then it results in an empty list. It will be more clear with an example. Let's say you have this setup: ``` w-[calc(1rem+0.25rem)] h-[calc(1rem+0.25rem)] size-5 ``` The first step is that this will result in: ``` w-5 h-5 size-5 ``` Then the `w-5 h-5` can turn into `size-5`. But the existing `size-5`, can also be replaced by the `size-5`. Internally, when we have a replacement, then we mark all the classes that can be replaced as "droppable", so they would be dropped from the list. But in this scenario we also marked `size-5` as droppable, resulting in an empty list. If an additional class existed: ``` w-[calc(1rem+0.25rem)] h-[calc(1rem+0.25rem)] size-5 flex ``` The result would be ``` flex ``` Instead of the expected: ``` size-5 flex ``` ## Test plan 1. Existing tests pass 2. Added new tests with and without an additional class
|
@RobinMalfait is attempting to deploy a commit to the Kristen's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Test plan