migrate-prefix.ts — tailwindcss Source File
Architecture documentation for migrate-prefix.ts, a typescript file in the tailwindcss codebase. 9 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR d13948d4_4434_bf78_9916_1ba327123c94["migrate-prefix.ts"] 42640952_ea63_55f1_1ff1_00816e2980ae["ast.ts"] d13948d4_4434_bf78_9916_1ba327123c94 --> 42640952_ea63_55f1_1ff1_00816e2980ae c203f636_607a_d332_b4c5_6a40c108f778["decl"] d13948d4_4434_bf78_9916_1ba327123c94 --> c203f636_607a_d332_b4c5_6a40c108f778 669e6a28_c71f_3c5e_9c53_915cede7da78["candidate.ts"] d13948d4_4434_bf78_9916_1ba327123c94 --> 669e6a28_c71f_3c5e_9c53_915cede7da78 d4b90da0_01b5_b21d_ff05_b37798744576["parseCandidate"] d13948d4_4434_bf78_9916_1ba327123c94 --> d4b90da0_01b5_b21d_ff05_b37798744576 af1a6ece_0432_a556_fd63_8cb4a91f12ad["plugin-api.ts"] d13948d4_4434_bf78_9916_1ba327123c94 --> af1a6ece_0432_a556_fd63_8cb4a91f12ad 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a["design-system.ts"] d13948d4_4434_bf78_9916_1ba327123c94 --> 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a ef204000_8998_5a6c_5455_324b37624713["segment.ts"] d13948d4_4434_bf78_9916_1ba327123c94 --> ef204000_8998_5a6c_5455_324b37624713 f712ed47_45d4_4e5a_dd73_fdefa1da71da["segment"] d13948d4_4434_bf78_9916_1ba327123c94 --> f712ed47_45d4_4e5a_dd73_fdefa1da71da fff09679_e13c_392d_23bb_cebc04ddb008["version.ts"] d13948d4_4434_bf78_9916_1ba327123c94 --> fff09679_e13c_392d_23bb_cebc04ddb008 832ea6ef_9a32_da8d_2421_b9aa3cf2d588["migrate-handle-empty-arbitrary-values.test.ts"] 832ea6ef_9a32_da8d_2421_b9aa3cf2d588 --> d13948d4_4434_bf78_9916_1ba327123c94 ee1d35bf_4335_a131_a900_1f9f4b90a0e1["migrate-modernize-arbitrary-values.test.ts"] ee1d35bf_4335_a131_a900_1f9f4b90a0e1 --> d13948d4_4434_bf78_9916_1ba327123c94 14c5b5eb_ad93_c522_2553_30e94134dbf5["migrate-prefix.test.ts"] 14c5b5eb_ad93_c522_2553_30e94134dbf5 --> d13948d4_4434_bf78_9916_1ba327123c94 75ba60a9_2614_1c57_ad40_3663d4315f3b["migrate.ts"] 75ba60a9_2614_1c57_ad40_3663d4315f3b --> d13948d4_4434_bf78_9916_1ba327123c94 c8809718_3b35_1fdb_ff99_94e375c7360a["prepare-config.ts"] c8809718_3b35_1fdb_ff99_94e375c7360a --> d13948d4_4434_bf78_9916_1ba327123c94 style d13948d4_4434_bf78_9916_1ba327123c94 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { decl } from '../../../../tailwindcss/src/ast'
import { parseCandidate, type Candidate } from '../../../../tailwindcss/src/candidate'
import type { Config } from '../../../../tailwindcss/src/compat/plugin-api'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
import { segment } from '../../../../tailwindcss/src/utils/segment'
import * as version from '../../utils/version'
let seenDesignSystems = new WeakSet<DesignSystem>()
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
// ... (81 more lines)
Domain
Subdomains
Dependencies
Imported By
- packages/@tailwindcss-upgrade/src/codemods/template/migrate-handle-empty-arbitrary-values.test.ts
- packages/@tailwindcss-upgrade/src/codemods/template/migrate-modernize-arbitrary-values.test.ts
- packages/@tailwindcss-upgrade/src/codemods/template/migrate-prefix.test.ts
- packages/@tailwindcss-upgrade/src/codemods/template/migrate.ts
- packages/@tailwindcss-upgrade/src/codemods/template/prepare-config.ts
Source
Frequently Asked Questions
What does migrate-prefix.ts do?
migrate-prefix.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeToolkit domain, Codemods subdomain.
What functions are defined in migrate-prefix.ts?
migrate-prefix.ts defines 3 function(s): extractV3Base, migratePrefix, migratePrefixValue.
What does migrate-prefix.ts depend on?
migrate-prefix.ts imports 9 module(s): ast.ts, candidate.ts, decl, design-system.ts, parseCandidate, plugin-api.ts, segment, segment.ts, and 1 more.
What files import migrate-prefix.ts?
migrate-prefix.ts is imported by 5 file(s): migrate-handle-empty-arbitrary-values.test.ts, migrate-modernize-arbitrary-values.test.ts, migrate-prefix.test.ts, migrate.ts, prepare-config.ts.
Where is migrate-prefix.ts in the architecture?
migrate-prefix.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/migrate-prefix.ts (domain: UpgradeToolkit, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/template).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free