migrate-at-apply.ts — tailwindcss Source File
Architecture documentation for migrate-at-apply.ts, a typescript file in the tailwindcss codebase. 9 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 587045dd_6997_cdb6_9548_cd81dc79a115["migrate-at-apply.ts"] da5d1116_ab2a_437a_6b13_c1429fd546fa["plugin-api.ts"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> da5d1116_ab2a_437a_6b13_c1429fd546fa 0255ffc0_a3d5_e883_5143_99660766448f["Config"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> 0255ffc0_a3d5_e883_5143_99660766448f bdedd2f6_da4b_69dc_e990_0814b59fbe6e["design-system.ts"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> bdedd2f6_da4b_69dc_e990_0814b59fbe6e 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62["DesignSystem"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62 bb9924cc_8308_a1f9_0e30_76de45a64970["segment.ts"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> bb9924cc_8308_a1f9_0e30_76de45a64970 c58cbb33_f3cc_0b4f_844a_15bf66a1dc61["segment"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> c58cbb33_f3cc_0b4f_844a_15bf66a1dc61 e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4["migrate.ts"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4 66c57db2_afd7_9e7b_cea6_76cdb074b086["migrateCandidate"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> 66c57db2_afd7_9e7b_cea6_76cdb074b086 7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"] 587045dd_6997_cdb6_9548_cd81dc79a115 --> 7c3c22f8_be1a_4490_9f3e_622280887fe1 031a0782_4b19_e996_bb0e_a2f940729176["migrate-at-apply.test.ts"] 031a0782_4b19_e996_bb0e_a2f940729176 --> 587045dd_6997_cdb6_9548_cd81dc79a115 9e542b1f_db4d_cc7b_b37d_1324d5719263["migrate.ts"] 9e542b1f_db4d_cc7b_b37d_1324d5719263 --> 587045dd_6997_cdb6_9548_cd81dc79a115 style 587045dd_6997_cdb6_9548_cd81dc79a115 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { AtRule, Plugin } from 'postcss'
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 { migrateCandidate } from '../template/migrate'
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
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does migrate-at-apply.ts do?
migrate-at-apply.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Codemods subdomain.
What functions are defined in migrate-at-apply.ts?
migrate-at-apply.ts defines 1 function(s): migrateAtApply.
What does migrate-at-apply.ts depend on?
migrate-at-apply.ts imports 9 module(s): Config, DesignSystem, design-system.ts, migrate.ts, migrateCandidate, plugin-api.ts, postcss, segment, and 1 more.
What files import migrate-at-apply.ts?
migrate-at-apply.ts is imported by 2 file(s): migrate-at-apply.test.ts, migrate.ts.
Where is migrate-at-apply.ts in the architecture?
migrate-at-apply.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/migrate-at-apply.ts (domain: CommandLineInterface, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/css).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free