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 CommandLineInterface Codemods 8 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  79c4e61a_7f2e_53a0_300b_705f6b159958["split.ts"]
  28a2f72d_350c_6647_bf9d_77c69e637045["default-map.ts"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> 28a2f72d_350c_6647_bf9d_77c69e637045
  cfb4af0e_7b2d_34a1_693a_90088443cfec["DefaultMap"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> cfb4af0e_7b2d_34a1_693a_90088443cfec
  bc267e18_3e03_cc17_3da0_cbc39f148f44["stylesheet.ts"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> bc267e18_3e03_cc17_3da0_cbc39f148f44
  b9897393_3e36_7806_d172_b9debcd215f6["Stylesheet"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> b9897393_3e36_7806_d172_b9debcd215f6
  8c8c71d8_c9b0_02ac_73ec_950510adcf7a["walk.ts"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> 8c8c71d8_c9b0_02ac_73ec_950510adcf7a
  dd7577d7_bdb0_88c5_438f_51bb090ec42a["walk"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> dd7577d7_bdb0_88c5_438f_51bb090ec42a
  df3a8122_6d4c_d7b5_82c0_a0aa72c62ab9["WalkAction"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> df3a8122_6d4c_d7b5_82c0_a0aa72c62ab9
  7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"]
  79c4e61a_7f2e_53a0_300b_705f6b159958 --> 7c3c22f8_be1a_4490_9f3e_622280887fe1
  f3e20782_7a7a_6d07_0472_a959db30007c["index.ts"]
  f3e20782_7a7a_6d07_0472_a959db30007c --> 79c4e61a_7f2e_53a0_300b_705f6b159958
  style 79c4e61a_7f2e_53a0_300b_705f6b159958 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 CommandLineInterface 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: 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