Home / Function/ getModuleInfo() — vite Function Reference

getModuleInfo() — vite Function Reference

Architecture documentation for the getModuleInfo() function in pluginContainer.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  87053f75_eb97_15a1_9d01_3e7bf0db1f33["getModuleInfo()"]
  e095f407_f809_eb3e_608e_d152e6847d0a["PluginContainer"]
  87053f75_eb97_15a1_9d01_3e7bf0db1f33 -->|defined in| e095f407_f809_eb3e_608e_d152e6847d0a
  0c657f10_5f2a_d708_4034_b4fc6ee0c7fa["getModuleInfo()"]
  87053f75_eb97_15a1_9d01_3e7bf0db1f33 -->|calls| 0c657f10_5f2a_d708_4034_b4fc6ee0c7fa
  style 87053f75_eb97_15a1_9d01_3e7bf0db1f33 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/pluginContainer.ts lines 1204–1240

  getModuleInfo(id: string): ModuleInfo | null {
    const clientModuleInfo = (
      this.environments.client as DevEnvironment
    ).pluginContainer.getModuleInfo(id)
    const ssrModuleInfo = (
      this.environments.ssr as DevEnvironment
    ).pluginContainer.getModuleInfo(id)

    if (clientModuleInfo == null && ssrModuleInfo == null) return null

    return new Proxy({} as any, {
      get: (_, key: string) => {
        // `meta` refers to `ModuleInfo.meta` of both environments, so we also
        // need to merge it here
        if (key === 'meta') {
          const meta: Record<string, any> = {}
          if (ssrModuleInfo) {
            Object.assign(meta, ssrModuleInfo.meta)
          }
          if (clientModuleInfo) {
            Object.assign(meta, clientModuleInfo.meta)
          }
          return meta
        }
        if (clientModuleInfo) {
          if (key in clientModuleInfo) {
            return clientModuleInfo[key as keyof ModuleInfo]
          }
        }
        if (ssrModuleInfo) {
          if (key in ssrModuleInfo) {
            return ssrModuleInfo[key as keyof ModuleInfo]
          }
        }
      },
    })
  }

Domain

Subdomains

Frequently Asked Questions

What does getModuleInfo() do?
getModuleInfo() is a function in the vite codebase, defined in packages/vite/src/node/server/pluginContainer.ts.
Where is getModuleInfo() defined?
getModuleInfo() is defined in packages/vite/src/node/server/pluginContainer.ts at line 1204.
What does getModuleInfo() call?
getModuleInfo() calls 1 function(s): getModuleInfo.

Analyze Your Own Codebase

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

Try Supermodel Free