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 d42d902c_ed1a_408e_b745_e2810d7e1b4b["migrateAtApply()"] 13933c8a_90a1_ea2c_81f3_e03051600481["migrate()"] 13933c8a_90a1_ea2c_81f3_e03051600481 -->|calls| d42d902c_ed1a_408e_b745_e2810d7e1b4b ccdccd11_44d9_ea22_dded_25c5b1cc55bb["migrateContents()"] ccdccd11_44d9_ea22_dded_25c5b1cc55bb -->|calls| d42d902c_ed1a_408e_b745_e2810d7e1b4b 49deb237_8387_627a_1b1d_a2683b818ef3["migrate()"] d42d902c_ed1a_408e_b745_e2810d7e1b4b -->|calls| 49deb237_8387_627a_1b1d_a2683b818ef3 03b8d706_a876_a776_0056_186ced5d6067["segment()"] d42d902c_ed1a_408e_b745_e2810d7e1b4b -->|calls| 03b8d706_a876_a776_0056_186ced5d6067 a8567d3a_b9d2_a553_2828_a5a6b62364da["migrateCandidate()"] d42d902c_ed1a_408e_b745_e2810d7e1b4b -->|calls| a8567d3a_b9d2_a553_2828_a5a6b62364da style d42d902c_ed1a_408e_b745_e2810d7e1b4b 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