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
  00f82a70_37cd_d9d2_64c8_29c748c197c6["createUtilitySignatureCache()"]
  20406e7c_6ee8_4626_dbef_5b37708f4d30["prepareDesignSystemStorage()"]
  20406e7c_6ee8_4626_dbef_5b37708f4d30 -->|calls| 00f82a70_37cd_d9d2_64c8_29c748c197c6
  c3b56f1d_0d90_0f17_2f55_85f3419d74bd["styleRule()"]
  00f82a70_37cd_d9d2_64c8_29c748c197c6 -->|calls| c3b56f1d_0d90_0f17_2f55_85f3419d74bd
  a9af385a_fd12_f1d8_7cf0_ccb9b281ca18["atRule()"]
  00f82a70_37cd_d9d2_64c8_29c748c197c6 -->|calls| a9af385a_fd12_f1d8_7cf0_ccb9b281ca18
  ff3b791b_69bb_dfca_8d4b_f92bd97ab054["temporarilyDisableThemeInline()"]
  00f82a70_37cd_d9d2_64c8_29c748c197c6 -->|calls| ff3b791b_69bb_dfca_8d4b_f92bd97ab054
  74157cfe_4a6c_d75a_a5ac_16fa6909752f["parseCandidate()"]
  00f82a70_37cd_d9d2_64c8_29c748c197c6 -->|calls| 74157cfe_4a6c_d75a_a5ac_16fa6909752f
  5f3acb43_b93f_4293_caaa_25ba26d38178["substituteAtApply()"]
  00f82a70_37cd_d9d2_64c8_29c748c197c6 -->|calls| 5f3acb43_b93f_4293_caaa_25ba26d38178
  84dbd847_e2eb_8fba_afa7_47012ee6086f["canonicalizeAst()"]
  00f82a70_37cd_d9d2_64c8_29c748c197c6 -->|calls| 84dbd847_e2eb_8fba_afa7_47012ee6086f
  af90c185_29a2_6c4c_ef06_b18f00f7655c["toCss()"]
  00f82a70_37cd_d9d2_64c8_29c748c197c6 -->|calls| af90c185_29a2_6c4c_ef06_b18f00f7655c
  style 00f82a70_37cd_d9d2_64c8_29c748c197c6 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.
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