Home / Function/ cleanupDepsCacheStaleDirs() — vite Function Reference

cleanupDepsCacheStaleDirs() — vite Function Reference

Architecture documentation for the cleanupDepsCacheStaleDirs() function in index.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  fdffa8ac_eb91_9c13_167c_dc593734ee66["cleanupDepsCacheStaleDirs()"]
  2f328851_91ee_fb05_63f0_4f466b9d6250["index.ts"]
  fdffa8ac_eb91_9c13_167c_dc593734ee66 -->|defined in| 2f328851_91ee_fb05_63f0_4f466b9d6250
  8f966b1b_ebbe_17e4_e14f_b8888709480c["loadCachedDepOptimizationMetadata()"]
  8f966b1b_ebbe_17e4_e14f_b8888709480c -->|calls| fdffa8ac_eb91_9c13_167c_dc593734ee66
  style fdffa8ac_eb91_9c13_167c_dc593734ee66 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/optimizer/index.ts lines 1402–1426

export async function cleanupDepsCacheStaleDirs(
  config: ResolvedConfig,
): Promise<void> {
  try {
    const cacheDir = path.resolve(config.cacheDir)
    if (fs.existsSync(cacheDir)) {
      const dirents = await fsp.readdir(cacheDir, { withFileTypes: true })
      for (const dirent of dirents) {
        if (dirent.isDirectory() && dirent.name.includes('_temp_')) {
          const tempDirPath = path.resolve(config.cacheDir, dirent.name)
          const stats = await fsp.stat(tempDirPath).catch(() => null)
          if (
            stats?.mtime &&
            Date.now() - stats.mtime.getTime() > MAX_TEMP_DIR_AGE_MS
          ) {
            debug?.(`removing stale cache temp dir ${tempDirPath}`)
            await fsp.rm(tempDirPath, { recursive: true, force: true })
          }
        }
      }
    }
  } catch (err) {
    config.logger.error(err)
  }
}

Subdomains

Frequently Asked Questions

What does cleanupDepsCacheStaleDirs() do?
cleanupDepsCacheStaleDirs() is a function in the vite codebase, defined in packages/vite/src/node/optimizer/index.ts.
Where is cleanupDepsCacheStaleDirs() defined?
cleanupDepsCacheStaleDirs() is defined in packages/vite/src/node/optimizer/index.ts at line 1402.
What calls cleanupDepsCacheStaleDirs()?
cleanupDepsCacheStaleDirs() is called by 1 function(s): loadCachedDepOptimizationMetadata.

Analyze Your Own Codebase

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

Try Supermodel Free