Home / Function/ propagateUpdate() — vite Function Reference

propagateUpdate() — vite Function Reference

Architecture documentation for the propagateUpdate() function in hmr.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  28b22657_9e1f_11af_307e_4e4ebf60be53["propagateUpdate()"]
  18db4f26_79f1_5b7d_b291_4feeaf95538f["hmr.ts"]
  28b22657_9e1f_11af_307e_4e4ebf60be53 -->|defined in| 18db4f26_79f1_5b7d_b291_4feeaf95538f
  f64686c5_88e2_949b_57b5_197f77dea3a7["updateModules()"]
  f64686c5_88e2_949b_57b5_197f77dea3a7 -->|calls| 28b22657_9e1f_11af_307e_4e4ebf60be53
  49bb1c89_8d09_e4c4_aebe_a57d1c034c93["isNodeWithinCircularImports()"]
  28b22657_9e1f_11af_307e_4e4ebf60be53 -->|calls| 49bb1c89_8d09_e4c4_aebe_a57d1c034c93
  d1f8b612_857c_d18a_b763_92f90bf93d2b["get()"]
  28b22657_9e1f_11af_307e_4e4ebf60be53 -->|calls| d1f8b612_857c_d18a_b763_92f90bf93d2b
  ed324c9b_ea3e_cec0_220f_91a0d4389eb8["areAllImportsAccepted()"]
  28b22657_9e1f_11af_307e_4e4ebf60be53 -->|calls| ed324c9b_ea3e_cec0_220f_91a0d4389eb8
  style 28b22657_9e1f_11af_307e_4e4ebf60be53 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/hmr.ts lines 756–843

function propagateUpdate(
  node: EnvironmentModuleNode,
  traversedModules: Set<EnvironmentModuleNode>,
  boundaries: PropagationBoundary[],
  currentChain: EnvironmentModuleNode[] = [node],
): HasDeadEnd {
  if (traversedModules.has(node)) {
    return false
  }
  traversedModules.add(node)

  // #7561
  // if the imports of `node` have not been analyzed, then `node` has not
  // been loaded in the browser and we should stop propagation.
  if (node.id && node.isSelfAccepting === undefined) {
    debugHmr?.(
      `[propagate update] stop propagation because not analyzed: ${colors.dim(
        node.id,
      )}`,
    )
    return false
  }

  if (node.isSelfAccepting) {
    // isSelfAccepting is only true for js and css
    const boundary = node as EnvironmentModuleNode & { type: 'js' | 'css' }
    boundaries.push({
      boundary,
      acceptedVia: boundary,
      isWithinCircularImport: isNodeWithinCircularImports(node, currentChain),
    })
    return false
  }

  // A partially accepted module with no importers is considered self accepting,
  // because the deal is "there are parts of myself I can't self accept if they
  // are used outside of me".
  // Also, the imported module (this one) must be updated before the importers,
  // so that they do get the fresh imported module when/if they are reloaded.
  if (node.acceptedHmrExports) {
    // acceptedHmrExports is only true for js and css
    const boundary = node as EnvironmentModuleNode & { type: 'js' | 'css' }
    boundaries.push({
      boundary,
      acceptedVia: boundary,
      isWithinCircularImport: isNodeWithinCircularImports(node, currentChain),
    })
  } else {
    if (!node.importers.size) {
      return true
    }
  }

  for (const importer of node.importers) {
    const subChain = currentChain.concat(importer)

    if (importer.acceptedHmrDeps.has(node)) {
      // acceptedHmrDeps has value only for js and css
      const boundary = importer as EnvironmentModuleNode & {
        type: 'js' | 'css'
      }
      boundaries.push({
        boundary,
        acceptedVia: node,
        isWithinCircularImport: isNodeWithinCircularImports(importer, subChain),
      })
      continue
    }

    if (node.id && node.acceptedHmrExports && importer.importedBindings) {
      const importedBindingsFromNode = importer.importedBindings.get(node.id)
      if (
        importedBindingsFromNode &&
        areAllImportsAccepted(importedBindingsFromNode, node.acceptedHmrExports)
      ) {
        continue
      }
    }

    if (
      !currentChain.includes(importer) &&

Domain

Subdomains

Called By

Frequently Asked Questions

What does propagateUpdate() do?
propagateUpdate() is a function in the vite codebase, defined in packages/vite/src/node/server/hmr.ts.
Where is propagateUpdate() defined?
propagateUpdate() is defined in packages/vite/src/node/server/hmr.ts at line 756.
What does propagateUpdate() call?
propagateUpdate() calls 3 function(s): areAllImportsAccepted, get, isNodeWithinCircularImports.
What calls propagateUpdate()?
propagateUpdate() is called by 1 function(s): updateModules.

Analyze Your Own Codebase

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

Try Supermodel Free