migratePrefix() — tailwindcss Function Reference
Architecture documentation for the migratePrefix() function in migrate-prefix.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD faeb1e90_cf89_2804_6ef1_386b3a9ffaba["migratePrefix()"] 91c7b7d7_b75e_448f_492f_b7e96c0ac0c5["isMajor()"] faeb1e90_cf89_2804_6ef1_386b3a9ffaba -->|calls| 91c7b7d7_b75e_448f_492f_b7e96c0ac0c5 85b46de2_edfa_9371_e2c6_e60f3f5346a2["decl()"] faeb1e90_cf89_2804_6ef1_386b3a9ffaba -->|calls| 85b46de2_edfa_9371_e2c6_e60f3f5346a2 c9435653_47da_ca15_e937_6532e96367aa["extractV3Base()"] faeb1e90_cf89_2804_6ef1_386b3a9ffaba -->|calls| c9435653_47da_ca15_e937_6532e96367aa 53cf41fe_5903_d247_3bb3_38414ba7d631["parseCandidate()"] faeb1e90_cf89_2804_6ef1_386b3a9ffaba -->|calls| 53cf41fe_5903_d247_3bb3_38414ba7d631 ec55634f_f6e4_3b8b_1267_0b251c4dade1["printCandidate()"] faeb1e90_cf89_2804_6ef1_386b3a9ffaba -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1 style faeb1e90_cf89_2804_6ef1_386b3a9ffaba fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-upgrade/src/codemods/template/migrate-prefix.ts lines 10–62
export function migratePrefix(
designSystem: DesignSystem,
userConfig: Config | null,
rawCandidate: string,
): string {
if (!designSystem.theme.prefix) return rawCandidate
if (!userConfig) return rawCandidate
if (!version.isMajor(3)) return rawCandidate
if (!seenDesignSystems.has(designSystem)) {
designSystem.utilities.functional('group', (value) => [
// To ensure that `@apply group` works when computing a signature
decl('--phantom-class', 'group'),
// To ensure `group` and `group/foo` are considered different classes
decl('--phantom-modifier', value.modifier?.value),
])
designSystem.utilities.functional('peer', (value) => [
// To ensure that `@apply peer` works when computing a signature
decl('--phantom-class', 'peer'),
// To ensure `peer` and `peer/foo` are considered different classes
decl('--phantom-modifier', value.modifier?.value),
])
seenDesignSystems.add(designSystem)
}
let v3Base = extractV3Base(designSystem, userConfig, rawCandidate)
if (!v3Base) return rawCandidate
// Only migrate candidates which are valid in v4
let originalPrefix = designSystem.theme.prefix
let candidate: Candidate | null = null
try {
designSystem.theme.prefix = null
let unprefixedCandidate =
rawCandidate.slice(0, v3Base.start) + v3Base.base + rawCandidate.slice(v3Base.end)
// Note: This is not a valid candidate in the original DesignSystem, so we
// can not use the `DesignSystem#parseCandidate` API here or otherwise this
// invalid candidate will be cached.
let candidates = [...parseCandidate(unprefixedCandidate, designSystem)]
if (candidates.length > 0) {
candidate = candidates[0]
}
} finally {
designSystem.theme.prefix = originalPrefix
}
if (!candidate) return rawCandidate
return designSystem.printCandidate(candidate)
}
Domain
Subdomains
Source
Frequently Asked Questions
What does migratePrefix() do?
migratePrefix() is a function in the tailwindcss codebase.
What does migratePrefix() call?
migratePrefix() calls 5 function(s): decl, extractV3Base, isMajor, parseCandidate, printCandidate.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free