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
  6bc468c3_f692_fb93_b3e2_cf2a6051b874["createUtilitySignatureCache()"]
  207ada18_60f2_10b9_7c9e_99bdb32f4ed7["prepareDesignSystemStorage()"]
  207ada18_60f2_10b9_7c9e_99bdb32f4ed7 -->|calls| 6bc468c3_f692_fb93_b3e2_cf2a6051b874
  9db2a11b_4852_e036_e394_622c7a90dd1f["styleRule()"]
  6bc468c3_f692_fb93_b3e2_cf2a6051b874 -->|calls| 9db2a11b_4852_e036_e394_622c7a90dd1f
  c35acfc6_964d_737e_6ecc_275e6f10293a["atRule()"]
  6bc468c3_f692_fb93_b3e2_cf2a6051b874 -->|calls| c35acfc6_964d_737e_6ecc_275e6f10293a
  affaaffb_bbfa_d683_8871_14297c28e46f["temporarilyDisableThemeInline()"]
  6bc468c3_f692_fb93_b3e2_cf2a6051b874 -->|calls| affaaffb_bbfa_d683_8871_14297c28e46f
  c98bf5b0_e31e_f92d_3810_96d1e1308d34["parseCandidate()"]
  6bc468c3_f692_fb93_b3e2_cf2a6051b874 -->|calls| c98bf5b0_e31e_f92d_3810_96d1e1308d34
  556f6ab2_af7d_ed90_84f0_6b49e632571a["substituteAtApply()"]
  6bc468c3_f692_fb93_b3e2_cf2a6051b874 -->|calls| 556f6ab2_af7d_ed90_84f0_6b49e632571a
  3c29a5ca_8e68_4fa2_4e91_392cf24c5a01["canonicalizeAst()"]
  6bc468c3_f692_fb93_b3e2_cf2a6051b874 -->|calls| 3c29a5ca_8e68_4fa2_4e91_392cf24c5a01
  e7a34553_0273_6202_4792_07409e33d8f0["toCss()"]
  6bc468c3_f692_fb93_b3e2_cf2a6051b874 -->|calls| e7a34553_0273_6202_4792_07409e33d8f0
  style 6bc468c3_f692_fb93_b3e2_cf2a6051b874 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()
      }
    })
  })
}

Domain

Subdomains

Frequently Asked Questions

What does createUtilitySignatureCache() do?
createUtilitySignatureCache() is a function in the tailwindcss codebase.
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