tailwindcss/packages/@tailwindcss-upgrade/src
Robin Malfait d2865c3e58
Remove layer(utilities) if imports contain @utility (#14738)
We have a migration that adds the `layer(…)` next to the `@import`
depending on the order of original values. For example:
```css
@import "tailwindcss/utilities":
@import "./foo.css":
@import "tailwindcss/components":
```

Will be turned into:
```css
@import "tailwindcss":
@import "./foo.css" layer(utilities):
```

Because it used to exist between `utilities` and `components`. Without
this it would be _after_ `components`.

This results in an issue if an import has (deeply) nested `@utility`
at-rules after migrations. This is because if this is generated:
```css
/* ./src/index.css */
@import "tailwindcss";
@import "./foo.css" layer(utilities);

/* ./src/foo.css */
@utility foo {
  color: red;
}
```

Once we interpret this (and thus flatten it), the final CSS would look
like:
```css
@layer utilities {
  @utility foo {
    color: red;
  }
}
```

This means that `@utility` is not top-level and an error would occur.

This fixes that by removing the `layer(…)` from the import if the
imported file (or any of its children) contains an `@utility`. This is
to ensure that once everything is imported and flattened, that all
`@utility` at-rules are top-level.
2024-10-21 23:46:24 +02:00
..
codemods Migrate static plugins with options to CSS (#14700) 2024-10-18 15:16:27 +02:00
commands/help Add initial codemod tooling (#14434) 2024-09-18 16:45:43 +02:00
template Ensure we migrate theme(spacing.1) to var(--spacing-1) correctly (#14724) 2024-10-19 15:19:10 +02:00
utils Include simple config objects when extracting static plugins (#14699) 2024-10-18 15:10:21 +02:00
index.test.ts Add simple JS config migration (#14639) 2024-10-11 15:27:53 +02:00
index.ts Remove layer(utilities) if imports contain @utility (#14738) 2024-10-21 23:46:24 +02:00
migrate-js-config.ts Upgrade: Allow corePlugins in JS config files (#14742) 2024-10-21 16:21:55 -04:00
migrate-postcss.ts Migrate simple PostCSS setup (#14612) 2024-10-10 15:09:14 +02:00
migrate.ts Remove layer(utilities) if imports contain @utility (#14738) 2024-10-21 23:46:24 +02:00
stylesheet.ts Remove layer(utilities) if imports contain @utility (#14738) 2024-10-21 23:46:24 +02:00