migrateAtApply() — tailwindcss Function Reference
Architecture documentation for the migrateAtApply() function in migrate-at-apply.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 03d4ca08_7ec2_689c_47d8_1be20f931aa5["migrateAtApply()"] 651d2af1_0a44_999a_c676_a66215d0923e["migrate()"] 651d2af1_0a44_999a_c676_a66215d0923e -->|calls| 03d4ca08_7ec2_689c_47d8_1be20f931aa5 b1aa79a5_bad0_a9e2_1c70_8e14489ee8dd["migrateContents()"] b1aa79a5_bad0_a9e2_1c70_8e14489ee8dd -->|calls| 03d4ca08_7ec2_689c_47d8_1be20f931aa5 a6633139_ebc1_9ae0_25b2_81b98419e559["migrate()"] 03d4ca08_7ec2_689c_47d8_1be20f931aa5 -->|calls| a6633139_ebc1_9ae0_25b2_81b98419e559 2a20ea29_c850_cd61_5600_aeebbe3dda66["segment()"] 03d4ca08_7ec2_689c_47d8_1be20f931aa5 -->|calls| 2a20ea29_c850_cd61_5600_aeebbe3dda66 cfb6acb7_b44a_cb88_3d14_926fd4e357da["migrateCandidate()"] 03d4ca08_7ec2_689c_47d8_1be20f931aa5 -->|calls| cfb6acb7_b44a_cb88_3d14_926fd4e357da style 03d4ca08_7ec2_689c_47d8_1be20f931aa5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-upgrade/src/codemods/css/migrate-at-apply.ts lines 7–61
export function migrateAtApply({
designSystem,
userConfig,
}: {
designSystem: DesignSystem | null
userConfig: Config | null
}): Plugin {
function migrate(atRule: AtRule) {
let utilities = atRule.params.split(/(\s+)/)
let important =
utilities[utilities.length - 1] === '!important' ||
utilities[utilities.length - 1] === '#{!important}' // Sass/SCSS
if (important) utilities.pop() // Remove `!important`
let params = utilities.map((part) => {
// Keep whitespace
if (part.trim() === '') return part
let variants = segment(part, ':')
let utility = variants.pop()!
// Apply the important modifier to all the rules if necessary
if (important && utility[0] !== '!' && utility[utility.length - 1] !== '!') {
utility += '!'
}
// Reconstruct the utility with the variants
return [...variants, utility].join(':')
})
return async () => {
if (!designSystem) return
// If we have a valid designSystem and config setup, we can run all
// candidate migrations on each utility
params = await Promise.all(
params.map(async (param) => await migrateCandidate(designSystem, userConfig, param)),
)
atRule.params = params.join('').trim()
}
}
return {
postcssPlugin: '@tailwindcss/upgrade/migrate-at-apply',
async OnceExit(root) {
let migrations: (() => void)[] = []
root.walkAtRules('apply', (atRule) => {
migrations.push(migrate(atRule))
})
await Promise.allSettled(migrations.map((m) => m()))
},
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does migrateAtApply() do?
migrateAtApply() is a function in the tailwindcss codebase.
What does migrateAtApply() call?
migrateAtApply() calls 3 function(s): migrate, migrateCandidate, segment.
What calls migrateAtApply()?
migrateAtApply() is called by 2 function(s): migrate, migrateContents.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free