Home / Function/ getModulesByFile() — vite Function Reference

getModulesByFile() — vite Function Reference

Architecture documentation for the getModulesByFile() function in mixedModuleGraph.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  98b45b52_fdf0_c791_ef33_cf0bce10f788["getModulesByFile()"]
  c1a5c030_6aae_0cbb_cc67_256559724512["ModuleGraph"]
  98b45b52_fdf0_c791_ef33_cf0bce10f788 -->|defined in| c1a5c030_6aae_0cbb_cc67_256559724512
  8f73b680_d5b9_383c_f695_c906b80fb1e6["handleHMRUpdate()"]
  8f73b680_d5b9_383c_f695_c906b80fb1e6 -->|calls| 98b45b52_fdf0_c791_ef33_cf0bce10f788
  a4168a1b_3e71_5cc9_a18d_c7ae3a38432d["getBackwardCompatibleBrowserModuleNode()"]
  98b45b52_fdf0_c791_ef33_cf0bce10f788 -->|calls| a4168a1b_3e71_5cc9_a18d_c7ae3a38432d
  6320d5f1_e9df_4579_295d_dff40d81f826["getBackwardCompatibleServerModuleNode()"]
  98b45b52_fdf0_c791_ef33_cf0bce10f788 -->|calls| 6320d5f1_e9df_4579_295d_dff40d81f826
  3497e769_085e_99ef_0a5f_baaff070d0f2["getModulesByFile()"]
  98b45b52_fdf0_c791_ef33_cf0bce10f788 -->|calls| 3497e769_085e_99ef_0a5f_baaff070d0f2
  b9c8cc4b_5575_ccfe_9243_d12c9ec34e91["getModuleById()"]
  98b45b52_fdf0_c791_ef33_cf0bce10f788 -->|calls| b9c8cc4b_5575_ccfe_9243_d12c9ec34e91
  style 98b45b52_fdf0_c791_ef33_cf0bce10f788 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/mixedModuleGraph.ts lines 341–364

  getModulesByFile(file: string): Set<ModuleNode> | undefined {
    // Until Vite 5.1.x, the moduleGraph contained modules from both the browser and server
    // We maintain backwards compatibility by returning a Set of module proxies assuming
    // that the modules for a certain file are the same in both the browser and server
    const clientModules = this._client.getModulesByFile(file)
    const ssrModules = this._ssr.getModulesByFile(file)
    if (!clientModules && !ssrModules) {
      return undefined
    }
    const result = new Set<ModuleNode>()
    if (clientModules) {
      for (const mod of clientModules) {
        result.add(this.getBackwardCompatibleBrowserModuleNode(mod)!)
      }
    }
    if (ssrModules) {
      for (const mod of ssrModules) {
        if (mod.id == null || !this._client.getModuleById(mod.id)) {
          result.add(this.getBackwardCompatibleServerModuleNode(mod)!)
        }
      }
    }
    return result
  }

Domain

Subdomains

Called By

Frequently Asked Questions

What does getModulesByFile() do?
getModulesByFile() is a function in the vite codebase, defined in packages/vite/src/node/server/mixedModuleGraph.ts.
Where is getModulesByFile() defined?
getModulesByFile() is defined in packages/vite/src/node/server/mixedModuleGraph.ts at line 341.
What does getModulesByFile() call?
getModulesByFile() calls 4 function(s): getBackwardCompatibleBrowserModuleNode, getBackwardCompatibleServerModuleNode, getModuleById, getModulesByFile.
What calls getModulesByFile()?
getModulesByFile() is called by 1 function(s): handleHMRUpdate.

Analyze Your Own Codebase

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

Try Supermodel Free