Home / Function/ createUtilitySignatureCache() — tailwindcss Function Reference

createUtilitySignatureCache() — tailwindcss Function Reference

Architecture documentation for the createUtilitySignatureCache() function in canonicalize-candidates.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd["createUtilitySignatureCache()"]
  7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e["canonicalize-candidates.ts"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|defined in| 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e
  81ec8f98_1fb2_d7c3_dd65_3a9e51b3be39["prepareDesignSystemStorage()"]
  81ec8f98_1fb2_d7c3_dd65_3a9e51b3be39 -->|calls| 3f0c9850_42a7_e7cb_36cc_12b1cb9274dd
  36be1773_d660_31ac_0b0b_88dbd7f6f7a8["styleRule()"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|calls| 36be1773_d660_31ac_0b0b_88dbd7f6f7a8
  f9b19679_c1f0_28d6_4d1a_31a10c52e42d["atRule()"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|calls| f9b19679_c1f0_28d6_4d1a_31a10c52e42d
  39ea4a1e_d717_23df_d73b_dd349e716a3b["temporarilyDisableThemeInline()"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|calls| 39ea4a1e_d717_23df_d73b_dd349e716a3b
  ef9ad758_33f4_0d23_fff8_8eeaf71d00d8["parseCandidate()"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|calls| ef9ad758_33f4_0d23_fff8_8eeaf71d00d8
  96876152_5423_5f9b_9f88_1db666070351["substituteAtApply()"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|calls| 96876152_5423_5f9b_9f88_1db666070351
  b634c4e7_2242_e72b_2b52_bbbae37fc41b["canonicalizeAst()"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|calls| b634c4e7_2242_e72b_2b52_bbbae37fc41b
  2da63033_d079_7b37_5cfb_3877674a70b9["toCss()"]
  3f0c9850_42a7_e7cb_36cc_12b1cb9274dd -->|calls| 2da63033_d079_7b37_5cfb_3877674a70b9
  style 3f0c9850_42a7_e7cb_36cc_12b1cb9274dd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/canonicalize-candidates.ts lines 2026–2066

function createUtilitySignatureCache(
  designSystem: DesignSystem,
): DesignSystem['storage'][typeof UTILITY_SIGNATURE_KEY] {
  return new DefaultMap((options: SignatureOptions) => {
    return new DefaultMap<string, string | Symbol>((utility) => {
      try {
        // Ensure the prefix is added to the utility if it is not already present.
        utility =
          designSystem.theme.prefix && !utility.startsWith(designSystem.theme.prefix)
            ? `${designSystem.theme.prefix}:${utility}`
            : utility

        // Use `@apply` to normalize the selector to `.x`
        let ast: AstNode[] = [styleRule('.x', [atRule('@apply', utility)])]

        temporarilyDisableThemeInline(designSystem, () => {
          // There's separate utility caches for respect important vs not
          // so we want to compile them both with `@theme inline` disabled
          for (let candidate of designSystem.parseCandidate(utility)) {
            designSystem.compileAstNodes(candidate, CompileAstFlags.RespectImportant)
          }

          substituteAtApply(ast, designSystem)
        })

        // Optimize the AST. This is needed such that any internal intermediate
        // nodes are gone. This will also cleanup declaration nodes with undefined
        // values or `--tw-sort` declarations.
        canonicalizeAst(designSystem, ast, options)

        // Compute the final signature, by generating the CSS for the utility
        let signature = toCss(ast)
        return signature
      } catch {
        // A unique symbol is returned to ensure that 2 signatures resulting in
        // `null` are not considered equal.
        return Symbol()
      }
    })
  })
}

Subdomains

Frequently Asked Questions

What does createUtilitySignatureCache() do?
createUtilitySignatureCache() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/canonicalize-candidates.ts.
Where is createUtilitySignatureCache() defined?
createUtilitySignatureCache() is defined in packages/tailwindcss/src/canonicalize-candidates.ts at line 2026.
What does createUtilitySignatureCache() call?
createUtilitySignatureCache() calls 7 function(s): atRule, canonicalizeAst, parseCandidate, styleRule, substituteAtApply, temporarilyDisableThemeInline, toCss.
What calls createUtilitySignatureCache()?
createUtilitySignatureCache() is called by 1 function(s): prepareDesignSystemStorage.

Analyze Your Own Codebase

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

Try Supermodel Free