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

Handle feedback from #14783 #14788

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions integrations/upgrade/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ test(
`,
'tailwind.config.js': js`module.exports = {}`,
'src/index.css': css`
@import 'tailwindcss/utilities';
@import 'tailwindcss/components';

/* No layer expected */
@import './my-components.css';
Expand All @@ -1571,7 +1571,7 @@ test(
/* Expecting a layer */
@import './my-other.css';

@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
`,
'src/my-components.css': css`
@layer components {
Expand Down Expand Up @@ -1600,16 +1600,16 @@ test(
expect(await fs.dumpFiles('./src/**/*.css')).toMatchInlineSnapshot(`
"
--- ./src/index.css ---
@import 'tailwindcss/utilities' layer(utilities);

/* No layer expected */
@import './my-components.css';

/* No layer expected */
@import './my-utilities.css';

/* Expecting a layer */
@import './my-other.css' layer(utilities);
@import './my-other.css' layer(components);

@import 'tailwindcss/utilities' layer(utilities);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's moved to the bottom because we replace @import 'tailwindcss/utilities'; with the new at-rule. Currently we just drop @import 'tailwindcss/components'; but we could replace that rule as well instead such that this import lives at the top. 🤔


--- ./src/my-components.css ---
@utility foo {
Expand Down
4 changes: 2 additions & 2 deletions packages/@tailwindcss-upgrade/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ async function run() {
)
if (!importedSheet) continue

// 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.
if (
!importedSheet.containsRule((node) => node.type === 'atrule' && node.name === 'utility')
) {
Expand Down