-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Ensure layer(…)
on @import
is only removed when @utility
is present
#14783
Conversation
380c128
to
1342dc8
Compare
1342dc8
to
4e5b48e
Compare
layer(…)
on @import
is correctlayer(…)
on @import
is only removed when @utility
is present
@@ -26,6 +22,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
- _Upgrade (experimental)_: Ensure `@import` statements for relative CSS files are actually migrated to use relative path syntax ([#14769](https://github.com/tailwindlabs/tailwindcss/pull/14769)) | |||
- _Upgrade (experimental)_: Only generate Preflight compatibility styles when Preflight is used ([#14773](https://github.com/tailwindlabs/tailwindcss/pull/14773)) | |||
- _Upgrade (experimental)_: Don't escape underscores when printing theme values migrated to CSS variables in arbitrary values (e.g. `m-[var(--spacing-1_5)]` instead of `m-[var(--spacing-1\_5)]`) ([#14778](https://github.com/tailwindlabs/tailwindcss/pull/14778)) | |||
- _Upgrade (experimental)_: Ensure `layer(…)` on `@import` is only removed when `@utility` is present ([#14783](https://github.com/tailwindlabs/tailwindcss/pull/14783)) | |||
|
|||
### Changed |
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.
Moved this down to be consistent with other changelog entries
// Only remove the `layer(…)` next to the import, if any of the children | ||
// contains an `@utility`. Otherwise the `@utility` will not be top-level. |
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.
// Only remove the `layer(…)` next to the import, if any of the children | |
// contains an `@utility`. Otherwise the `@utility` will not be top-level. | |
// Only remove the `layer(…)` next to the import if any of the children | |
// contain `@utility`. Otherwise `@utility` will not be top-level. |
/* Expecting a layer */ | ||
@import './my-other.css'; | ||
|
||
@import 'tailwindcss/components'; |
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.
Is it important that components
comes last here? If that's not a crucial part of the test it seems better to me to structure things closer to how they would be in a real project.
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.
Going to merge as-is so we can tag a release since this will already be an improvement over what's there but would like to come back and address the feedback here too before we forget 👍
This PR is a continuation of #14783 to handle the feedback on that PR. 1. Update the test to be more realistic 2. Updated the comment --------- Co-authored-by: Adam Wathan <[email protected]>
This PR fixes an issue where
layer(…)
next to imports were removed where they shouldn't have been removed.The issue exists if any of the
@import
nodes in a file contains@utility
, if that's the case then we removed thelayer(…)
next to all@import
nodes.Before we were checking if the current sheet contained
@utility
or in any of its children (sub-@import
nodes).This fixes that by looping over the
@import
nodes in the current sheet, and looking for the@utility
in the associated/imported file. This way we update each node individually.Test plan:
Added a dedicated integration test to make sure all codemods together result in the correct result. Input:
tailwindcss/integrations/upgrade/index.test.ts
Lines 2076 to 2108 in 96e8908
Output:
tailwindcss/integrations/upgrade/index.test.ts
Lines 2116 to 2126 in 96e8908