migratePrefix() — tailwindcss Function Reference
Architecture documentation for the migratePrefix() function in migrate-prefix.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 087d2224_9aa6_c6e5_3a75_d99cf251cb04["migratePrefix()"] d13948d4_4434_bf78_9916_1ba327123c94["migrate-prefix.ts"] 087d2224_9aa6_c6e5_3a75_d99cf251cb04 -->|defined in| d13948d4_4434_bf78_9916_1ba327123c94 8d08c9fd_45a1_f37c_a879_6fd2c9991403["isMajor()"] 087d2224_9aa6_c6e5_3a75_d99cf251cb04 -->|calls| 8d08c9fd_45a1_f37c_a879_6fd2c9991403 c203f636_607a_d332_b4c5_6a40c108f778["decl()"] 087d2224_9aa6_c6e5_3a75_d99cf251cb04 -->|calls| c203f636_607a_d332_b4c5_6a40c108f778 140850c7_e088_0df8_4c28_edc0207aa6e0["extractV3Base()"] 087d2224_9aa6_c6e5_3a75_d99cf251cb04 -->|calls| 140850c7_e088_0df8_4c28_edc0207aa6e0 d4b90da0_01b5_b21d_ff05_b37798744576["parseCandidate()"] 087d2224_9aa6_c6e5_3a75_d99cf251cb04 -->|calls| d4b90da0_01b5_b21d_ff05_b37798744576 87ba7eab_3a52_d53e_dfd4_e507e9763b55["printCandidate()"] 087d2224_9aa6_c6e5_3a75_d99cf251cb04 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55 style 087d2224_9aa6_c6e5_3a75_d99cf251cb04 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, defined in packages/@tailwindcss-upgrade/src/codemods/template/migrate-prefix.ts.
Where is migratePrefix() defined?
migratePrefix() is defined in packages/@tailwindcss-upgrade/src/codemods/template/migrate-prefix.ts at line 10.
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