migrate-preflight.ts — tailwindcss Source File
Architecture documentation for migrate-preflight.ts, a typescript file in the tailwindcss codebase. 15 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR f67a6019_88a0_ffd1_f91c_1a51645f6931["migrate-preflight.ts"] 8d84257d_f3b2_cdf8_542f_835967da0481["apply-config-to-theme.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 8d84257d_f3b2_cdf8_542f_835967da0481 1767219e_c38a_227c_492b_5d47634d54a4["keyPathToCssProperty"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 1767219e_c38a_227c_492b_5d47634d54a4 da5d1116_ab2a_437a_6b13_c1429fd546fa["plugin-api.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> da5d1116_ab2a_437a_6b13_c1429fd546fa 0255ffc0_a3d5_e883_5143_99660766448f["Config"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 0255ffc0_a3d5_e883_5143_99660766448f bdedd2f6_da4b_69dc_e990_0814b59fbe6e["design-system.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> bdedd2f6_da4b_69dc_e990_0814b59fbe6e 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62["DesignSystem"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62 1f643124_89df_1d95_f8fd_e4036c7301de["to-key-path.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 1f643124_89df_1d95_f8fd_e4036c7301de 05d44181_6631_c1fa_4a63_96653e28f99c["toKeyPath"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 05d44181_6631_c1fa_4a63_96653e28f99c d9175aea_5971_a6c1_773d_004ce3789372["value-parser.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> d9175aea_5971_a6c1_773d_004ce3789372 1b8f1c54_b1e9_e18d_0719_b7ad92808185["walk.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185 4982d9ce_98d4_85d9_44af_7cc47b93c482["walk"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 4982d9ce_98d4_85d9_44af_7cc47b93c482 47187d1b_a6f7_f734_0752_446b87b5cd9e["WalkAction"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 47187d1b_a6f7_f734_0752_446b87b5cd9e 472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 472e1b98_afcf_f1f2_ad91_916d742bb731 8ff4bb92_b963_efb6_cca2_1da4b3ea849b["dedent"] f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 8ff4bb92_b963_efb6_cca2_1da4b3ea849b style f67a6019_88a0_ffd1_f91c_1a51645f6931 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import dedent from 'dedent'
import postcss, { type Plugin, type Root } from 'postcss'
import { keyPathToCssProperty } from '../../../../tailwindcss/src/compat/apply-config-to-theme'
import type { Config } from '../../../../tailwindcss/src/compat/plugin-api'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
import { toKeyPath } from '../../../../tailwindcss/src/utils/to-key-path'
import * as ValueParser from '../../../../tailwindcss/src/value-parser'
import { walk, WalkAction } from '../../../../tailwindcss/src/walk'
import * as version from '../../utils/version'
// Defaults in v4
const DEFAULT_BORDER_COLOR = 'currentcolor'
const css = dedent
const BORDER_COLOR_COMPATIBILITY_CSS = css`
/*
The default border color has changed to \`currentcolor\` in Tailwind CSS v4,
so we've added these compatibility styles to make sure everything still
looks the same as it did with Tailwind CSS v3.
If we ever want to remove these styles, we need to add an explicit border
color utility to any element that depends on these defaults.
*/
@layer base {
*,
::after,
::before,
::backdrop,
::file-selector-button {
border-color: theme(borderColor.DEFAULT);
}
}
`
export function migratePreflight({
designSystem,
userConfig,
}: {
designSystem: DesignSystem | null
userConfig?: Config | null
}): Plugin {
// @ts-expect-error
let defaultBorderColor = userConfig?.theme?.borderColor?.DEFAULT
function canResolveThemeValue(path: string) {
if (!designSystem) return false
let variable = `--${keyPathToCssProperty(toKeyPath(path))}` as const
return Boolean(designSystem.theme.get([variable]))
}
function migrate(root: Root) {
// CSS for backwards compatibility with v3 should only injected in v3
// projects and not v4 projects.
if (!version.isMajor(3)) return
let isTailwindRoot = false
root.walkAtRules('import', (node) => {
if (
/['"]tailwindcss['"]/.test(node.params) ||
/['"]tailwindcss\/preflight['"]/.test(node.params)
// ... (125 more lines)
Domain
Subdomains
Dependencies
Imported By
Source
Frequently Asked Questions
What does migrate-preflight.ts do?
migrate-preflight.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-preflight.ts?
migrate-preflight.ts defines 3 function(s): eventuallyUnquote, migratePreflight, substituteFunctionsInValue.
What does migrate-preflight.ts depend on?
migrate-preflight.ts imports 15 module(s): Config, DesignSystem, WalkAction, apply-config-to-theme.ts, dedent, design-system.ts, keyPathToCssProperty, plugin-api.ts, and 7 more.
What files import migrate-preflight.ts?
migrate-preflight.ts is imported by 2 file(s): migrate-preflight.test.ts, migrate.ts.
Where is migrate-preflight.ts in the architecture?
migrate-preflight.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/migrate-preflight.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