Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mst-mkt
Copy link

@mst-mkt mst-mkt commented Dec 15, 2024

issue

resolve #104

description

The main fix for this PR is to eliminate errors that occur in tailwindcss v4.

The following changes were made.

  • added toColorValue to utilities.js since toColorValue in tailwindcss was removed.
  • since featureFlags in tailwindcss is probably gone, require is now enclosed in try-catch to support both versions.
  • changed peerDependencies to 4.x || 3.x.

Confirmed to work with tailwindcss@4.0.0-beta.7 in the environment at hand

Copy link
Owner

@adoxography adoxography left a 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
Comment on lines 3 to 11
const { flagEnabled } = (() => {
try {
// from tailwind v4, featureFlags is not exist
// eslint-disable-next-line global-require
return require('tailwindcss/lib/featureFlags');
} catch {
return {};
}
})();
Copy link
Owner

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?

Copy link
Author

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.

@mst-mkt
Copy link
Author

mst-mkt commented Dec 23, 2024

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.

@mst-mkt mst-mkt changed the title Tailwind CSS v4.0 support Fix some errors with Tailwind CSS v4.0 Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tailwind CSS v4.0 support
2 participants