Home / Function/ isVariableUsed() — tailwindcss Function Reference

isVariableUsed() — tailwindcss Function Reference

Architecture documentation for the isVariableUsed() function in ast.ts from the tailwindcss codebase.

Function typescript PostCSSPlugin AST calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  1a695257_28e4_0604_3f02_e52886aa117e["isVariableUsed()"]
  b9cbffa4_c352_cf3c_268f_cbb174fb3a47["ast.ts"]
  1a695257_28e4_0604_3f02_e52886aa117e -->|defined in| b9cbffa4_c352_cf3c_268f_cbb174fb3a47
  9f2a64dc_05ff_3425_1af8_f2dbd33c3b9a["optimizeAst()"]
  9f2a64dc_05ff_3425_1af8_f2dbd33c3b9a -->|calls| 1a695257_28e4_0604_3f02_e52886aa117e
  e7db6358_7af5_e4b2_792d_749691a304cc["add()"]
  1a695257_28e4_0604_3f02_e52886aa117e -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  45cb4617_2116_e947_4a90_d9e2642b9325["getOptions()"]
  1a695257_28e4_0604_3f02_e52886aa117e -->|calls| 45cb4617_2116_e947_4a90_d9e2642b9325
  2820372c_b982_9e06_fc23_f8f4ac308d00["get()"]
  1a695257_28e4_0604_3f02_e52886aa117e -->|calls| 2820372c_b982_9e06_fc23_f8f4ac308d00
  style 1a695257_28e4_0604_3f02_e52886aa117e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/ast.ts lines 903–929

function isVariableUsed(
  variable: string,
  theme: Theme,
  variableDependencies: Map<string, Set<string>>,
  alreadySeenVariables: Set<string> = new Set(),
): boolean {
  // Break recursions when visiting a variable twice
  if (alreadySeenVariables.has(variable)) {
    return true
  } else {
    alreadySeenVariables.add(variable)
  }

  let options = theme.getOptions(variable)
  if (options & (ThemeOptions.STATIC | ThemeOptions.USED)) {
    return true
  } else {
    let dependencies = variableDependencies.get(variable) ?? []
    for (let dependency of dependencies) {
      if (isVariableUsed(dependency, theme, variableDependencies, alreadySeenVariables)) {
        return true
      }
    }
  }

  return false
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does isVariableUsed() do?
isVariableUsed() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/ast.ts.
Where is isVariableUsed() defined?
isVariableUsed() is defined in packages/tailwindcss/src/ast.ts at line 903.
What does isVariableUsed() call?
isVariableUsed() calls 3 function(s): add, get, getOptions.
What calls isVariableUsed()?
isVariableUsed() is called by 1 function(s): optimizeAst.

Analyze Your Own Codebase

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

Try Supermodel Free