Home / Function/ expectedCache() — tailwindcss Function Reference

expectedCache() — tailwindcss Function Reference

Architecture documentation for the expectedCache() function in version.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  a4ad5100_39b5_6a90_6dd5_49937eaa0f11["expectedCache()"]
  4ef7606d_6db1_3d23_3a99_f5d91d921964["installedTailwindVersion()"]
  a4ad5100_39b5_6a90_6dd5_49937eaa0f11 -->|calls| 4ef7606d_6db1_3d23_3a99_f5d91d921964
  style a4ad5100_39b5_6a90_6dd5_49937eaa0f11 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/utils/version.ts lines 34–60

let expectedCache = new DefaultMap((base) => {
  try {
    // This will report a problem if the package.json/package-lock.json
    // mismatches with the installed version in node_modules.
    //
    // Also tested this with Bun and PNPM, both seem to work fine.
    execSync('npm ls tailwindcss --json', { cwd: base, stdio: 'pipe' })
    return installedTailwindVersion(base)
  } catch (_e) {
    try {
      let e = _e as { stdout: Buffer }
      let data = JSON.parse(e.stdout.toString())

      return (
        // Could be a sub-dependency issue, but we are only interested in
        // the top-level version mismatch.
        /"(.*?)" from the root project/.exec(data.dependencies.tailwindcss.invalid)?.[1] ??
        // Fallback to the installed version
        installedTailwindVersion(base)
      )
    } catch {
      // We don't know how to verify, so let's just return the installed
      // version to not block the user.
      return installedTailwindVersion(base)
    }
  }
})

Subdomains

Frequently Asked Questions

What does expectedCache() do?
expectedCache() is a function in the tailwindcss codebase.
What does expectedCache() call?
expectedCache() calls 1 function(s): installedTailwindVersion.

Analyze Your Own Codebase

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

Try Supermodel Free