Home / Function/ hmrShouldReload() — vue Function Reference

hmrShouldReload() — vue Function Reference

Architecture documentation for the hmrShouldReload() function in compileScript.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  77a507e4_1c27_8178_ab4a_e01ee29e1b0d["hmrShouldReload()"]
  b9f12a63_b611_1b00_0717_3ff21d7ce156["compileScript.ts"]
  77a507e4_1c27_8178_ab4a_e01ee29e1b0d -->|defined in| b9f12a63_b611_1b00_0717_3ff21d7ce156
  3c328c48_43e7_b764_1bc5_97a37b54ee62["parse()"]
  3c328c48_43e7_b764_1bc5_97a37b54ee62 -->|calls| 77a507e4_1c27_8178_ab4a_e01ee29e1b0d
  5b047687_7011_90aa_7925_63a1d469fe2b["isImportUsed()"]
  77a507e4_1c27_8178_ab4a_e01ee29e1b0d -->|calls| 5b047687_7011_90aa_7925_63a1d469fe2b
  style 77a507e4_1c27_8178_ab4a_e01ee29e1b0d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/compiler-sfc/src/compileScript.ts lines 1896–1916

export function hmrShouldReload(
  prevImports: Record<string, ImportBinding>,
  next: SFCDescriptor
): boolean {
  if (!next.scriptSetup) {
    return false
  }

  const isTS = next.scriptSetup.lang === 'ts' || next.scriptSetup.lang === 'tsx'
  // for each previous import, check if its used status remain the same based on
  // the next descriptor's template
  for (const key in prevImports) {
    // if an import was previous unused, but now is used, we need to force
    // reload so that the script now includes that import.
    if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next, isTS)) {
      return true
    }
  }

  return false
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does hmrShouldReload() do?
hmrShouldReload() is a function in the vue codebase, defined in packages/compiler-sfc/src/compileScript.ts.
Where is hmrShouldReload() defined?
hmrShouldReload() is defined in packages/compiler-sfc/src/compileScript.ts at line 1896.
What does hmrShouldReload() call?
hmrShouldReload() calls 1 function(s): isImportUsed.
What calls hmrShouldReload()?
hmrShouldReload() is called by 1 function(s): parse.

Analyze Your Own Codebase

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

Try Supermodel Free