migrate-missing-layers.ts — tailwindcss Source File
Architecture documentation for migrate-missing-layers.ts, a typescript file in the tailwindcss codebase. 3 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 22b81643_65c2_ce37_e597_13959f1f8254["migrate-missing-layers.ts"] ef204000_8998_5a6c_5455_324b37624713["segment.ts"] 22b81643_65c2_ce37_e597_13959f1f8254 --> ef204000_8998_5a6c_5455_324b37624713 f712ed47_45d4_4e5a_dd73_fdefa1da71da["segment"] 22b81643_65c2_ce37_e597_13959f1f8254 --> f712ed47_45d4_4e5a_dd73_fdefa1da71da ba54c7c3_7b1e_9984_bfef_a693a3df2d84["postcss"] 22b81643_65c2_ce37_e597_13959f1f8254 --> ba54c7c3_7b1e_9984_bfef_a693a3df2d84 eb33b378_40f9_8aa4_2ce0_91f69294a359["migrate-missing-layers.test.ts"] eb33b378_40f9_8aa4_2ce0_91f69294a359 --> 22b81643_65c2_ce37_e597_13959f1f8254 67f80607_3a88_f275_79a1_b9557100d939["migrate.ts"] 67f80607_3a88_f275_79a1_b9557100d939 --> 22b81643_65c2_ce37_e597_13959f1f8254 style 22b81643_65c2_ce37_e597_13959f1f8254 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { AtRule, type ChildNode, type Plugin, type Root } from 'postcss'
import { segment } from '../../../../tailwindcss/src/utils/segment'
export function migrateMissingLayers(): Plugin {
function migrate(root: Root) {
let lastLayer = ''
let bucket: ChildNode[] = []
let buckets: [layer: string, bucket: typeof bucket][] = []
let firstLayerName: string | null = null
root.each((node) => {
if (node.type === 'atrule') {
// Known Tailwind directives that should not be inside a layer.
if (
node.name === 'config' ||
node.name === 'source' ||
node.name === 'theme' ||
node.name === 'utility' ||
node.name === 'custom-variant' ||
node.name === 'variant'
) {
if (bucket.length > 0) {
buckets.push([lastLayer, bucket.splice(0)])
}
return
}
// Base
if (
(node.name === 'tailwind' && node.params === 'base') ||
(node.name === 'import' && node.params.match(/^["']tailwindcss\/base["']/))
) {
if (bucket.length > 0) {
buckets.push([lastLayer, bucket.splice(0)])
}
firstLayerName ??= 'base'
lastLayer = 'base'
return
}
// Components
if (
(node.name === 'tailwind' && node.params === 'components') ||
(node.name === 'import' && node.params.match(/^["']tailwindcss\/components["']/))
) {
if (bucket.length > 0) {
buckets.push([lastLayer, bucket.splice(0)])
}
firstLayerName ??= 'components'
lastLayer = 'components'
return
}
// Utilities
if (
(node.name === 'tailwind' && node.params === 'utilities') ||
(node.name === 'import' && node.params.match(/^["']tailwindcss\/utilities["']/))
) {
// ... (102 more lines)
Domain
Subdomains
Functions
Dependencies
- postcss
- segment
- segment.ts
Imported By
Source
Frequently Asked Questions
What does migrate-missing-layers.ts do?
migrate-missing-layers.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-missing-layers.ts?
migrate-missing-layers.ts defines 1 function(s): migrateMissingLayers.
What does migrate-missing-layers.ts depend on?
migrate-missing-layers.ts imports 3 module(s): postcss, segment, segment.ts.
What files import migrate-missing-layers.ts?
migrate-missing-layers.ts is imported by 2 file(s): migrate-missing-layers.test.ts, migrate.ts.
Where is migrate-missing-layers.ts in the architecture?
migrate-missing-layers.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/migrate-missing-layers.ts (domain: UpgradeToolkit, 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