Home / File/ migrate-variants-directive.ts — tailwindcss Source File

migrate-variants-directive.ts — tailwindcss Source File

Architecture documentation for migrate-variants-directive.ts, a typescript file in the tailwindcss codebase. 1 imports, 2 dependents.

File typescript CommandLineInterface Codemods 1 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  8403a095_a391_8879_03a7_dca5d41871c7["migrate-variants-directive.ts"]
  7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"]
  8403a095_a391_8879_03a7_dca5d41871c7 --> 7c3c22f8_be1a_4490_9f3e_622280887fe1
  abead924_2390_edac_c530_1a639293bbdf["migrate-variants-directive.test.ts"]
  abead924_2390_edac_c530_1a639293bbdf --> 8403a095_a391_8879_03a7_dca5d41871c7
  9e542b1f_db4d_cc7b_b37d_1324d5719263["migrate.ts"]
  9e542b1f_db4d_cc7b_b37d_1324d5719263 --> 8403a095_a391_8879_03a7_dca5d41871c7
  style 8403a095_a391_8879_03a7_dca5d41871c7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { type Plugin, type Root } from 'postcss'

export function migrateVariantsDirective(): Plugin {
  function migrate(root: Root) {
    root.walkAtRules('variants', (node) => {
      // Migrate `@variants` to `@utility` because `@variants` make the classes
      // an actual utility.
      // ```css
      // @variants hover {
      //   .foo {}
      // }
      // ```
      //
      // Means that you can do this in your HTML:
      // ```html
      // <div class="focus:foo"></div>
      // ```
      //
      // Notice the `focus:`, even though we _only_ configured the `hover`
      // variant.
      //
      // This means that we can convert it to an `@layer utilities` rule. Later,
      // this will get converted to an `@utility` rule.
      if (node.name === 'variants') {
        node.name = 'layer'
        node.params = 'utilities'
      }
    })
  }

  return {
    postcssPlugin: '@tailwindcss/upgrade/migrate-variants-directive',
    OnceExit: migrate,
  }
}

Subdomains

Dependencies

  • postcss

Frequently Asked Questions

What does migrate-variants-directive.ts do?
migrate-variants-directive.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Codemods subdomain.
What functions are defined in migrate-variants-directive.ts?
migrate-variants-directive.ts defines 1 function(s): migrateVariantsDirective.
What does migrate-variants-directive.ts depend on?
migrate-variants-directive.ts imports 1 module(s): postcss.
What files import migrate-variants-directive.ts?
migrate-variants-directive.ts is imported by 2 file(s): migrate-variants-directive.test.ts, migrate.ts.
Where is migrate-variants-directive.ts in the architecture?
migrate-variants-directive.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/migrate-variants-directive.ts (domain: CommandLineInterface, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/css).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free