Home / Function/ getLockfileHash() — vite Function Reference

getLockfileHash() — vite Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  4b382358_e92d_2c3c_8d21_bc94472fd5da["getLockfileHash()"]
  2f328851_91ee_fb05_63f0_4f466b9d6250["index.ts"]
  4b382358_e92d_2c3c_8d21_bc94472fd5da -->|defined in| 2f328851_91ee_fb05_63f0_4f466b9d6250
  8f966b1b_ebbe_17e4_e14f_b8888709480c["loadCachedDepOptimizationMetadata()"]
  8f966b1b_ebbe_17e4_e14f_b8888709480c -->|calls| 4b382358_e92d_2c3c_8d21_bc94472fd5da
  74146d64_5b7b_78cd_e4e7_8edffa229212["getDepHash()"]
  74146d64_5b7b_78cd_e4e7_8edffa229212 -->|calls| 4b382358_e92d_2c3c_8d21_bc94472fd5da
  934a26da_8b90_f4d4_a1d6_df7aa4fead12["lookupFile()"]
  4b382358_e92d_2c3c_8d21_bc94472fd5da -->|calls| 934a26da_8b90_f4d4_a1d6_df7aa4fead12
  a9bd45ce_8339_2b77_7543_41c306ebdb02["tryStatSync()"]
  4b382358_e92d_2c3c_8d21_bc94472fd5da -->|calls| a9bd45ce_8339_2b77_7543_41c306ebdb02
  9d025481_71dc_8fbb_c07e_b6e74a08a45a["getHash()"]
  4b382358_e92d_2c3c_8d21_bc94472fd5da -->|calls| 9d025481_71dc_8fbb_c07e_b6e74a08a45a
  style 4b382358_e92d_2c3c_8d21_bc94472fd5da fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/optimizer/index.ts lines 1309–1331

function getLockfileHash(environment: Environment): string {
  const lockfilePath = lookupFile(environment.config.root, lockfilePaths)
  let content = lockfilePath ? fs.readFileSync(lockfilePath, 'utf-8') : ''
  if (lockfilePath) {
    const normalizedLockfilePath = lockfilePath.replaceAll('\\', '/')
    const lockfileFormat = lockfileFormats.find((f) =>
      normalizedLockfilePath.endsWith(f.path),
    )!
    if (lockfileFormat.checkPatchesDir) {
      // Default of https://github.com/ds300/patch-package
      const baseDir = lockfilePath.slice(0, -lockfileFormat.path.length)
      const fullPath = path.join(
        baseDir,
        lockfileFormat.checkPatchesDir as string,
      )
      const stat = tryStatSync(fullPath)
      if (stat?.isDirectory()) {
        content += stat.mtimeMs.toString()
      }
    }
  }
  return getHash(content)
}

Subdomains

Frequently Asked Questions

What does getLockfileHash() do?
getLockfileHash() is a function in the vite codebase, defined in packages/vite/src/node/optimizer/index.ts.
Where is getLockfileHash() defined?
getLockfileHash() is defined in packages/vite/src/node/optimizer/index.ts at line 1309.
What does getLockfileHash() call?
getLockfileHash() calls 3 function(s): getHash, lookupFile, tryStatSync.
What calls getLockfileHash()?
getLockfileHash() is called by 2 function(s): getDepHash, loadCachedDepOptimizationMetadata.

Analyze Your Own Codebase

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

Try Supermodel Free