Home / Function/ compileAstNodes() — tailwindcss Function Reference

compileAstNodes() — tailwindcss Function Reference

Architecture documentation for the compileAstNodes() function in compile.ts from the tailwindcss codebase.

Function typescript Oxide PreProcessors calls 5 called by 2

Entity Profile

Dependency Diagram

graph TD
  8b088e47_7f37_81e9_fe8a_5da6d3f5e245["compileAstNodes()"]
  eea0ec96_6369_abc2_64b3_490868392e31["compile.ts"]
  8b088e47_7f37_81e9_fe8a_5da6d3f5e245 -->|defined in| eea0ec96_6369_abc2_64b3_490868392e31
  ad08c258_e5c2_4cd4_c935_0925a940458e["compileCandidates()"]
  ad08c258_e5c2_4cd4_c935_0925a940458e -->|calls| 8b088e47_7f37_81e9_fe8a_5da6d3f5e245
  e557c8a4_bb27_ee44_c462_9e238157ad04["buildDesignSystem()"]
  e557c8a4_bb27_ee44_c462_9e238157ad04 -->|calls| 8b088e47_7f37_81e9_fe8a_5da6d3f5e245
  d3da176b_5d25_508c_c940_26dbd0d5b553["compileBaseUtility()"]
  8b088e47_7f37_81e9_fe8a_5da6d3f5e245 -->|calls| d3da176b_5d25_508c_c940_26dbd0d5b553
  3330a25c_8114_660c_a3c7_8f1aaa37457d["escape()"]
  8b088e47_7f37_81e9_fe8a_5da6d3f5e245 -->|calls| 3330a25c_8114_660c_a3c7_8f1aaa37457d
  2c6d0804_78a7_51d1_3b46_0c20049b6db2["getPropertySort()"]
  8b088e47_7f37_81e9_fe8a_5da6d3f5e245 -->|calls| 2c6d0804_78a7_51d1_3b46_0c20049b6db2
  56a8f250_915d_aea4_3d75_5c379bef9a8a["applyImportant()"]
  8b088e47_7f37_81e9_fe8a_5da6d3f5e245 -->|calls| 56a8f250_915d_aea4_3d75_5c379bef9a8a
  74e35fd7_c887_0191_82e9_5c47ae4932d3["applyVariant()"]
  8b088e47_7f37_81e9_fe8a_5da6d3f5e245 -->|calls| 74e35fd7_c887_0191_82e9_5c47ae4932d3
  style 8b088e47_7f37_81e9_fe8a_5da6d3f5e245 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/compile.ts lines 123–175

export function compileAstNodes(
  candidate: Candidate,
  designSystem: DesignSystem,
  flags: CompileAstFlags,
) {
  let asts = compileBaseUtility(candidate, designSystem)
  if (asts.length === 0) return []

  let respectImportant = designSystem.important && Boolean(flags & CompileAstFlags.RespectImportant)

  let rules: {
    node: AstNode
    propertySort: {
      order: number[]
      count: number
    }
  }[] = []

  let selector = `.${escape(candidate.raw)}`

  for (let nodes of asts) {
    let propertySort = getPropertySort(nodes)

    // If the candidate itself is important then we want to always mark
    // the utility as important. However, at a design system level we want
    // to be able to opt-out when using things like `@apply`
    if (candidate.important || respectImportant) {
      applyImportant(nodes)
    }

    let node: StyleRule = {
      kind: 'rule',
      selector,
      nodes,
    }

    for (let variant of candidate.variants) {
      let result = applyVariant(node, variant, designSystem.variants)

      // When the variant results in `null`, it means that the variant cannot be
      // applied to the rule. Discard the candidate and continue to the next
      // one.
      if (result === null) return []
    }

    rules.push({
      node,
      propertySort,
    })
  }

  return rules
}

Domain

Subdomains

Frequently Asked Questions

What does compileAstNodes() do?
compileAstNodes() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/compile.ts.
Where is compileAstNodes() defined?
compileAstNodes() is defined in packages/tailwindcss/src/compile.ts at line 123.
What does compileAstNodes() call?
compileAstNodes() calls 5 function(s): applyImportant, applyVariant, compileBaseUtility, escape, getPropertySort.
What calls compileAstNodes()?
compileAstNodes() is called by 2 function(s): buildDesignSystem, compileCandidates.

Analyze Your Own Codebase

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

Try Supermodel Free