Home / File/ split.ts — tailwindcss Source File

split.ts — tailwindcss Source File

Architecture documentation for split.ts, a typescript file in the tailwindcss codebase. 8 imports, 1 dependents.

File typescript UpgradeToolkit Codemods 8 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1["split.ts"]
  c056448b_f7a2_9149_54e8_f0f8470fe3aa["default-map.ts"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> c056448b_f7a2_9149_54e8_f0f8470fe3aa
  bf2992f6_4a37_8536_70f8_94b13631027d["DefaultMap"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> bf2992f6_4a37_8536_70f8_94b13631027d
  41fd12a7_15c2_7d83_2e55_c5b9a8faf9b1["stylesheet.ts"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> 41fd12a7_15c2_7d83_2e55_c5b9a8faf9b1
  c890fa7b_6e17_4e5d_74bf_b797d0f757b8["Stylesheet"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> c890fa7b_6e17_4e5d_74bf_b797d0f757b8
  200c8408_4d17_9364_423b_0ce2d40b1e09["walk.ts"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> 200c8408_4d17_9364_423b_0ce2d40b1e09
  fb009bc2_68d9_5c0f_7fa7_fa364488e50a["walk"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> fb009bc2_68d9_5c0f_7fa7_fa364488e50a
  5abba2e8_591c_8b93_1630_783a6907b808["WalkAction"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> 5abba2e8_591c_8b93_1630_783a6907b808
  ba54c7c3_7b1e_9984_bfef_a693a3df2d84["postcss"]
  e46aa0a1_8e0f_d880_965e_ea61032b8ef1 --> ba54c7c3_7b1e_9984_bfef_a693a3df2d84
  b2eb6cbf_d28d_9ec7_61c1_8992d8f4efb8["index.ts"]
  b2eb6cbf_d28d_9ec7_61c1_8992d8f4efb8 --> e46aa0a1_8e0f_d880_965e_ea61032b8ef1
  style e46aa0a1_8e0f_d880_965e_ea61032b8ef1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import postcss from 'postcss'
import { DefaultMap } from '../../../../tailwindcss/src/utils/default-map'
import { Stylesheet, type StylesheetId } from '../../stylesheet'
import { walk, WalkAction } from '../../utils/walk'

export async function split(stylesheets: Stylesheet[]) {
  let stylesheetsById = new Map<StylesheetId, Stylesheet>()
  let stylesheetsByFile = new Map<string, Stylesheet>()

  for (let sheet of stylesheets) {
    stylesheetsById.set(sheet.id, sheet)

    if (sheet.file) {
      stylesheetsByFile.set(sheet.file, sheet)
    }
  }

  // Keep track of sheets that contain `@utility` rules
  let requiresSplit = new Set<Stylesheet>()

  for (let sheet of stylesheets) {
    // Root files don't need to be split
    if (sheet.isTailwindRoot) continue

    let containsUtility = false
    let containsUnsafe = sheet.layers().size > 0

    walk(sheet.root, (node) => {
      if (node.type === 'atrule' && node.name === 'utility') {
        containsUtility = true
      }

      // Safe to keep without splitting
      else if (
        // An `@import "…" layer(…)` is safe
        (node.type === 'atrule' && node.name === 'import' && node.params.includes('layer(')) ||
        // @layer blocks are safe
        (node.type === 'atrule' && node.name === 'layer') ||
        // Comments are safe
        node.type === 'comment'
      ) {
        return WalkAction.Skip
      }

      // Everything else is not safe, and requires a split
      else {
        containsUnsafe = true
      }

      // We already know we need to split this sheet
      if (containsUtility && containsUnsafe) {
        return WalkAction.Stop
      }

      return WalkAction.Skip
    })

    if (containsUtility && containsUnsafe) {
      requiresSplit.add(sheet)
    }
// ... (198 more lines)

Subdomains

Functions

Frequently Asked Questions

What does split.ts do?
split.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 split.ts?
split.ts defines 1 function(s): split.
What does split.ts depend on?
split.ts imports 8 module(s): DefaultMap, Stylesheet, WalkAction, default-map.ts, postcss, stylesheet.ts, walk, walk.ts.
What files import split.ts?
split.ts is imported by 1 file(s): index.ts.
Where is split.ts in the architecture?
split.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/split.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