createPreComputedUtilitiesCache() — tailwindcss Function Reference
Architecture documentation for the createPreComputedUtilitiesCache() function in canonicalize-candidates.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 139df69f_ddbd_4db4_0de1_bb2eee5278c0["createPreComputedUtilitiesCache()"] 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e["canonicalize-candidates.ts"] 139df69f_ddbd_4db4_0de1_bb2eee5278c0 -->|defined in| 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e 81ec8f98_1fb2_d7c3_dd65_3a9e51b3be39["prepareDesignSystemStorage()"] 81ec8f98_1fb2_d7c3_dd65_3a9e51b3be39 -->|calls| 139df69f_ddbd_4db4_0de1_bb2eee5278c0 a15b3c4a_76ff_0090_fc86_bac24f0a4135["isValidSpacingMultiplier()"] 139df69f_ddbd_4db4_0de1_bb2eee5278c0 -->|calls| a15b3c4a_76ff_0090_fc86_bac24f0a4135 5bcf4886_1230_a8ff_7302_a26cc5a9a525["get()"] 139df69f_ddbd_4db4_0de1_bb2eee5278c0 -->|calls| 5bcf4886_1230_a8ff_7302_a26cc5a9a525 style 139df69f_ddbd_4db4_0de1_bb2eee5278c0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/canonicalize-candidates.ts lines 2334–2379
function createPreComputedUtilitiesCache(
designSystem: DesignSystem,
): DesignSystem['storage'][typeof PRE_COMPUTED_UTILITIES_KEY] {
return new DefaultMap((options: SignatureOptions) => {
let signatures = designSystem.storage[UTILITY_SIGNATURE_KEY].get(options)
let lookup = new DefaultMap<string, string[]>(() => [])
// Right now all plugins are implemented using functions so they are a black
// box. Let's use the `getClassList` and consider every known suggestion as a
// static utility for now.
for (let [className, meta] of designSystem.getClassList()) {
let signature = signatures.get(className)
if (typeof signature !== 'string') continue
// Skip the utility if `-{utility}-0` has the same signature as
// `{utility}-0` (its positive version). This will prefer positive values
// over negative values.
if (className[0] === '-' && className.endsWith('-0')) {
let positiveSignature = signatures.get(className.slice(1))
if (typeof positiveSignature === 'string' && signature === positiveSignature) {
continue
}
}
lookup.get(signature).push(className)
designSystem.storage[UTILITY_PROPERTIES_KEY].get(options).get(className)
for (let modifier of meta.modifiers) {
// Modifiers representing numbers can be computed and don't need to be
// pre-computed. Doing the math and at the time of writing this, this
// would save you 250k additionally pre-computed utilities...
if (isValidSpacingMultiplier(modifier)) {
continue
}
let classNameWithModifier = `${className}/${modifier}`
let signature = signatures.get(classNameWithModifier)
if (typeof signature !== 'string') continue
lookup.get(signature).push(classNameWithModifier)
designSystem.storage[UTILITY_PROPERTIES_KEY].get(options).get(classNameWithModifier)
}
}
return lookup
})
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does createPreComputedUtilitiesCache() do?
createPreComputedUtilitiesCache() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/canonicalize-candidates.ts.
Where is createPreComputedUtilitiesCache() defined?
createPreComputedUtilitiesCache() is defined in packages/tailwindcss/src/canonicalize-candidates.ts at line 2334.
What does createPreComputedUtilitiesCache() call?
createPreComputedUtilitiesCache() calls 2 function(s): get, isValidSpacingMultiplier.
What calls createPreComputedUtilitiesCache()?
createPreComputedUtilitiesCache() 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