Home / Function/ migrateContent() — tailwindcss Function Reference

migrateContent() — tailwindcss Function Reference

Architecture documentation for the migrateContent() function in migrate-js-config.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  d7c75f44_f7ab_dadd_4dd7_67ec16ab58d7["migrateContent()"]
  dc1d7e71_14d1_dd51_5d14_8265f9e59cce["migrateJsConfig()"]
  dc1d7e71_14d1_dd51_5d14_8265f9e59cce -->|calls| d7c75f44_f7ab_dadd_4dd7_67ec16ab58d7
  27aa9538_b0bd_da2b_0b97_fadc09b51c58["autodetectedSourceFiles()"]
  d7c75f44_f7ab_dadd_4dd7_67ec16ab58d7 -->|calls| 27aa9538_b0bd_da2b_0b97_fadc09b51c58
  bcec69b7_7226_e054_9c8f_a218eb638212["patternSourceFiles()"]
  d7c75f44_f7ab_dadd_4dd7_67ec16ab58d7 -->|calls| bcec69b7_7226_e054_9c8f_a218eb638212
  style d7c75f44_f7ab_dadd_4dd7_67ec16ab58d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts lines 341–390

async function migrateContent(
  unresolvedConfig: Config,
  configPath: string,
  base: string,
): Promise<{ base: string; pattern: string }[]> {
  let autoContentFiles = autodetectedSourceFiles(base)

  let sources = []
  let contentIsRelative = (() => {
    if (!unresolvedConfig.content) return false
    if (Array.isArray(unresolvedConfig.content)) return false
    if (unresolvedConfig.content.relative) return true
    if (unresolvedConfig.future === 'all') return false
    return unresolvedConfig.future?.relativeContentPathsByDefault ?? false
  })()

  let sourceGlobs = Array.isArray(unresolvedConfig.content)
    ? unresolvedConfig.content.map((pattern) => ({ base, pattern }))
    : (unresolvedConfig.content?.files ?? []).map((pattern) => {
        if (typeof pattern === 'string' && contentIsRelative) {
          return { base: path.dirname(configPath), pattern: pattern }
        }
        return { base, pattern }
      })

  for (let { base, pattern } of sourceGlobs) {
    if (typeof pattern !== 'string') {
      throw new Error('Unsupported content value: ' + pattern)
    }

    let sourceFiles = patternSourceFiles({
      base,
      pattern: pattern[0] === '!' ? pattern.slice(1) : pattern,
      negated: pattern[0] === '!',
    })

    let autoContentContainsAllSourceFiles = true
    for (let sourceFile of sourceFiles) {
      if (!autoContentFiles.includes(sourceFile)) {
        autoContentContainsAllSourceFiles = false
        break
      }
    }

    if (!autoContentContainsAllSourceFiles) {
      sources.push({ base, pattern })
    }
  }
  return sources
}

Subdomains

Called By

Frequently Asked Questions

What does migrateContent() do?
migrateContent() is a function in the tailwindcss codebase.
What does migrateContent() call?
migrateContent() calls 2 function(s): autodetectedSourceFiles, patternSourceFiles.
What calls migrateContent()?
migrateContent() is called by 1 function(s): migrateJsConfig.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free