Home / File/ migrate-preflight.test.ts — tailwindcss Source File

migrate-preflight.test.ts — tailwindcss Source File

Architecture documentation for migrate-preflight.test.ts, a typescript file in the tailwindcss codebase. 11 imports, 0 dependents.

File typescript CommandLineInterface Codemods 11 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6["migrate-preflight.test.ts"]
  472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> 472e1b98_afcf_f1f2_ad91_916d742bb731
  a088502e_f5da_0531_fbd0_c586a964c369["format-nodes.ts"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> a088502e_f5da_0531_fbd0_c586a964c369
  9f6b611c_7303_0355_74f7_03283a44c6d0["formatNodes"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> 9f6b611c_7303_0355_74f7_03283a44c6d0
  f67a6019_88a0_ffd1_f91c_1a51645f6931["migrate-preflight.ts"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> f67a6019_88a0_ffd1_f91c_1a51645f6931
  0838eb2e_5580_246c_b5a8_b68fb91edccc["migratePreflight"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> 0838eb2e_5580_246c_b5a8_b68fb91edccc
  a1d91fdc_e00f_534f_abf6_a58adf4778f1["sort-buckets.ts"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> a1d91fdc_e00f_534f_abf6_a58adf4778f1
  bbbe5224_64f9_042a_8b85_2e287c62c4d1["sortBuckets"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> bbbe5224_64f9_042a_8b85_2e287c62c4d1
  08129f89_e6ef_0092_629d_821c60228c89["node"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> 08129f89_e6ef_0092_629d_821c60228c89
  8ff4bb92_b963_efb6_cca2_1da4b3ea849b["dedent"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> 8ff4bb92_b963_efb6_cca2_1da4b3ea849b
  7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> 7c3c22f8_be1a_4490_9f3e_622280887fe1
  f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"]
  45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3
  style 45ec79c2_d411_4cc2_0b36_0b2e19cf72e6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { __unstable__loadDesignSystem } from '@tailwindcss/node'
import dedent from 'dedent'
import postcss from 'postcss'
import { expect, it, vi } from 'vitest'
import * as versions from '../../utils/version'
import { formatNodes } from './format-nodes'
import { migratePreflight } from './migrate-preflight'
import { sortBuckets } from './sort-buckets'
vi.spyOn(versions, 'isMajor').mockReturnValue(true)

const css = dedent

async function migrate(input: string) {
  let designSystem = await __unstable__loadDesignSystem(
    css`
      @import 'tailwindcss';
    `,
    { base: __dirname },
  )

  return postcss()
    .use(migratePreflight({ designSystem }))
    .use(sortBuckets())
    .use(formatNodes())
    .process(input, { from: expect.getState().testPath })
    .then((result) => result.css)
}

it("should add compatibility CSS after the `@import 'tailwindcss'`", async () => {
  expect(
    await migrate(css`
      @import 'tailwindcss';
    `),
  ).toMatchInlineSnapshot(`
    "@import 'tailwindcss';

    /*
      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: var(--color-gray-200, currentcolor);
      }
    }"
  `)
})

it('should add the compatibility CSS after the last `@import`', async () => {
  expect(
    await migrate(css`
      @import 'tailwindcss';
// ... (266 more lines)

Subdomains

Functions

Frequently Asked Questions

What does migrate-preflight.test.ts do?
migrate-preflight.test.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.test.ts?
migrate-preflight.test.ts defines 1 function(s): migrate.
What does migrate-preflight.test.ts depend on?
migrate-preflight.test.ts imports 11 module(s): dedent, format-nodes.ts, formatNodes, migrate-preflight.ts, migratePreflight, node, postcss, sort-buckets.ts, and 3 more.
Where is migrate-preflight.test.ts in the architecture?
migrate-preflight.test.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/migrate-preflight.test.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