Home / Function/ compileAstNodes() — tailwindcss Function Reference

compileAstNodes() — tailwindcss Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  e57db502_ed4e_4f14_1b2a_b25af3c0477d["compileAstNodes()"]
  214bac69_e516_bea4_67fa_4e9e092ced3b["compile.ts"]
  e57db502_ed4e_4f14_1b2a_b25af3c0477d -->|defined in| 214bac69_e516_bea4_67fa_4e9e092ced3b
  f611bd99_74d3_1161_f7f5_4c1d73c377e5["compileCandidates()"]
  f611bd99_74d3_1161_f7f5_4c1d73c377e5 -->|calls| e57db502_ed4e_4f14_1b2a_b25af3c0477d
  9b965fd7_d8e9_0b43_cd5d_c9294ab598ed["buildDesignSystem()"]
  9b965fd7_d8e9_0b43_cd5d_c9294ab598ed -->|calls| e57db502_ed4e_4f14_1b2a_b25af3c0477d
  aa6d74f0_f677_1f2e_7377_fa1f895e27ab["compileBaseUtility()"]
  e57db502_ed4e_4f14_1b2a_b25af3c0477d -->|calls| aa6d74f0_f677_1f2e_7377_fa1f895e27ab
  433dc479_0296_0a89_fd12_79fc4ea2b8bd["escape()"]
  e57db502_ed4e_4f14_1b2a_b25af3c0477d -->|calls| 433dc479_0296_0a89_fd12_79fc4ea2b8bd
  e0256065_d4b7_9362_cc77_233a58f9282b["getPropertySort()"]
  e57db502_ed4e_4f14_1b2a_b25af3c0477d -->|calls| e0256065_d4b7_9362_cc77_233a58f9282b
  ca093c73_8d7d_4f1b_08e7_2d3c0882a486["applyImportant()"]
  e57db502_ed4e_4f14_1b2a_b25af3c0477d -->|calls| ca093c73_8d7d_4f1b_08e7_2d3c0882a486
  adc16be1_fc13_4928_7caf_2acb3a5e9877["applyVariant()"]
  e57db502_ed4e_4f14_1b2a_b25af3c0477d -->|calls| adc16be1_fc13_4928_7caf_2acb3a5e9877
  style e57db502_ed4e_4f14_1b2a_b25af3c0477d 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