Add --stream flag to canonicalize subcommand#19796
Add --stream flag to canonicalize subcommand#19796RobinMalfait merged 3 commits intotailwindlabs:mainfrom
--stream flag to canonicalize subcommand#19796Conversation
Adds a streaming mode to `tailwindcss canonicalize` for use as a long-running sidecar process. With `--stream`, the CLI reads candidate groups from stdin line by line and writes canonicalized results to stdout, keeping the design system loaded across requests. This enables non-JS tools (formatters, editor plugins, etc.) to canonicalize Tailwind classes via simple line-based I/O without needing to reload the design system for each request.
|
Caution Review failedPull request was closed or merged during review WalkthroughAdds a streaming mode to the canonicalize command via a new 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required. |
RobinMalfait
left a comment
There was a problem hiding this comment.
Hey! I appreciate the PR. The canonicalize command was still in a proof of concept phase but was already merged so we can test things out.
That said, I do like the --stream option so that we don't have to spawn the command every time, just like you mentioned. One thing you can do is collect all groups first, and then call it once. But I can see that that might not be as ergonomic.
I'm also conflicted on the --stream name, we might change this before we properly release this. I like --stdio as an option as well, but we already communicate via stdin/stdout even without this long running process so let's keep --stream for now.
Thanks!
|
Thanks for the review and the merge! On batching — in my case ( One thing I'd love to see before this is properly released: renaming the subcommand to something like |
|
The initial version used to be called Maybe we rename it in the future, or introduce separate commands, but for now we want to keep it as canonicalize. |
|
That makes sense — canonicalize covers more than just ordering. Thanks for the context on the earlier |
Summary
--streamflag totailwindcss canonicalizethat reads candidate groups from stdin line by line and writes canonicalized results to stdoutMotivation
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 starttailwindcss canonicalize --streamonce and send candidate groups over stdin as needed:Related discussion: #19736