-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix some errors with Tailwind CSS v4.0 #105
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the changes in here largely make sense, I'm not comfortable bumping the supported version until I can get passing tests (npm run test
). This plugin taps into the underlying postcss
AST to be able to style pseudoclasses of pseudoelements (e.g. ::-webkit-scrollbar-thumb:hover
) and I'm concerned that with the new rust implementation tailwindcss@v4
is rolling out, that logic will have broken.
src/variants.js
Outdated
const { flagEnabled } = (() => { | ||
try { | ||
// from tailwind v4, featureFlags is not exist | ||
// eslint-disable-next-line global-require | ||
return require('tailwindcss/lib/featureFlags'); | ||
} catch { | ||
return {}; | ||
} | ||
})(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't just ignore feature flags. For flags that are being checked in v3, we need to know how v4 handles their behaviour: are they not present because their behaviour has been removed (what this change assumes), or are they not present because their behaviour has become default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the v4 source code and found the following @media (hover: hover) { &:hover }
.
Therefore, I modified it to return it when import is not possible (≈v4).
https://github.com/tailwindlabs/tailwindcss/blob/36dfe1f574ac3adf24d77479faafe9bec563d985/packages/tailwindcss/src/variants.ts#L703-L705
I do not think this implementation is smart. Please point out if there is another better implementation.
I created this PR for the purpose of fixing some errors, but through owner comments and some fixes I found that it is not so easy to deal with the new version. If you do not need this PR for your response, please feel free to close it. |
issue
resolve #104
description
The main fix for this PR is to eliminate errors that occur in tailwindcss v4.
The following changes were made.
toColorValue
toutilities.js
sincetoColorValue
in tailwindcss was removed.featureFlags
in tailwindcss is probably gone,require
is now enclosed intry-catch
to support both versions.4.x || 3.x
.Confirmed to work with
tailwindcss@4.0.0-beta.7
in the environment at hand