Skip to content

Commit

Permalink
use walkAtRules instead of the visitor API
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Sep 23, 2024
1 parent e646ac0 commit e361319
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function walkDepth<T>(rule: Walkable<T>, cb: (rule: T) => void) {
}

export function migrateAtLayerUtilities(): Plugin {
async function migrate(atRule: AtRule) {
function migrate(atRule: AtRule) {
// Only migrate `@layer utilities` and `@layer components`.
if (atRule.params !== 'utilities' && atRule.params !== 'components') return

Expand Down Expand Up @@ -312,10 +312,12 @@ export function migrateAtLayerUtilities(): Plugin {

return {
postcssPlugin: '@tailwindcss/upgrade/migrate-at-layer-utilities',
AtRule: {
layer: migrate,
},
OnceExit: async (root) => {
// Migrate `@layer utilities` and `@layer components` into `@utility`.
// Using this instead of the visitor API in case we want to use
// postcss-nesting in the future.
root.walkAtRules('layer', migrate)

// Prettier is used to generate cleaner output, but it's only used on the
// nodes that were marked as `pretty` during the migration.
{
Expand Down

0 comments on commit e361319

Please sign in to comment.