-
-
Notifications
You must be signed in to change notification settings - Fork 174
Description
Hi Tailwind CSS team! I'm a maintainer of Oxc. We're currently working on Tailwind CSS class sorting support in Oxfmt (a Rust-based JavaScript formatter aiming for 100% Prettier compatibility), and it's nearly complete. Tailwind CSS sorting is the most requested feature from users looking to migrate from Prettier to Oxfmt.
Implementation in Oxfmt
For Tailwind CSS support, we're using getTailwindConfig and sortClasses from this plugin under the hood to follow Tailwind CSS's official sorting rules. However, this package doesn't export these two functions, making it impossible to use them directly. We're currently using pnpm patch as a workaround to export them for development, but this isn't an ideal long-term solution—especially since we're patching a minified package.
Proposed Changes
In addition to exporting these two functions, we'd need small modifications to make the integration work smoothly and more performantly:
-
Change
getTailwindConfigto acceptconfigDirandconfigPath(naming TBD) instead of inferring them fromfilepath. This allows us to avoid redundant calls toresolvePrettierConfigPathwhen we already have the config paths resolved on the Oxfmt side. It also avoids bundlingprettierin Oxfmt, sinceresolvePrettierConfigPathdepends on it. -
Re-export
getTailwindConfigandsortClassesfrom a new file likelib.tsusing theexportsfield to make it tree-shakeable. Currently,index.tscontainslet base = await loadPlugins();, which imports all parsers and prevents tree-shaking.
Would you consider making these changes and exporting these two functions? This would greatly facilitate our integration efforts and ensure consistency with Tailwind CSS's official sorting logic. All Tailwind CSS users would benefit, as they could use a faster formatter without losing their beloved Tailwind CSS sorting feature.
I'd be happy to work on a PR for this if you're open to the idea. Thank you for your consideration!