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
  4ee4f3fc_1324_3723_32ed_86ee2e89fc90["expectedCache()"]
  472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"]
  4ee4f3fc_1324_3723_32ed_86ee2e89fc90 -->|defined in| 472e1b98_afcf_f1f2_ad91_916d742bb731
  32d4722d_8ebf_aac6_17f1_b44e71c91dab["installedTailwindVersion()"]
  4ee4f3fc_1324_3723_32ed_86ee2e89fc90 -->|calls| 32d4722d_8ebf_aac6_17f1_b44e71c91dab
  style 4ee4f3fc_1324_3723_32ed_86ee2e89fc90 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, defined in packages/@tailwindcss-upgrade/src/utils/version.ts.
Where is expectedCache() defined?
expectedCache() is defined in packages/@tailwindcss-upgrade/src/utils/version.ts at line 34.
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