Home / Function/ ensureVersionQuery() — vite Function Reference

ensureVersionQuery() — vite Function Reference

Architecture documentation for the ensureVersionQuery() function in resolve.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  943b70a3_1c84_7955_97b8_7f6e05f2f986["ensureVersionQuery()"]
  dcff87b0_a8ea_57a2_3b29_a7b8f19986f3["resolve.ts"]
  943b70a3_1c84_7955_97b8_7f6e05f2f986 -->|defined in| dcff87b0_a8ea_57a2_3b29_a7b8f19986f3
  0ac6860f_bc2f_9818_86d4_22179cc9c8ba["oxcResolvePlugin()"]
  0ac6860f_bc2f_9818_86d4_22179cc9c8ba -->|calls| 943b70a3_1c84_7955_97b8_7f6e05f2f986
  50ac7e51_9f94_e985_bfec_ae95273b23b0["isInNodeModules()"]
  943b70a3_1c84_7955_97b8_7f6e05f2f986 -->|calls| 50ac7e51_9f94_e985_bfec_ae95273b23b0
  908e9e35_950f_ad37_ffa9_0058622aa7e8["isOptimizable()"]
  943b70a3_1c84_7955_97b8_7f6e05f2f986 -->|calls| 908e9e35_950f_ad37_ffa9_0058622aa7e8
  1948f092_e5a5_076b_2f59_79ef22dec191["injectQuery()"]
  943b70a3_1c84_7955_97b8_7f6e05f2f986 -->|calls| 1948f092_e5a5_076b_2f59_79ef22dec191
  style 943b70a3_1c84_7955_97b8_7f6e05f2f986 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/resolve.ts lines 522–548

function ensureVersionQuery(
  resolved: string,
  id: string,
  options: InternalResolveOptions,
  depsOptimizer?: DepsOptimizer,
): string {
  if (
    !options.isBuild &&
    !options.scan &&
    depsOptimizer &&
    !(resolved === normalizedClientEntry || resolved === normalizedEnvEntry)
  ) {
    // Ensure that direct imports of node_modules have the same version query
    // as if they would have been imported through a bare import
    // Use the original id to do the check as the resolved id may be the real
    // file path after symlinks resolution
    const isNodeModule = isInNodeModules(id) || isInNodeModules(resolved)

    if (isNodeModule && !DEP_VERSION_RE.test(resolved)) {
      const versionHash = depsOptimizer.metadata.browserHash
      if (versionHash && isOptimizable(resolved, depsOptimizer.options)) {
        resolved = injectQuery(resolved, `v=${versionHash}`)
      }
    }
  }
  return resolved
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does ensureVersionQuery() do?
ensureVersionQuery() is a function in the vite codebase, defined in packages/vite/src/node/plugins/resolve.ts.
Where is ensureVersionQuery() defined?
ensureVersionQuery() is defined in packages/vite/src/node/plugins/resolve.ts at line 522.
What does ensureVersionQuery() call?
ensureVersionQuery() calls 3 function(s): injectQuery, isInNodeModules, isOptimizable.
What calls ensureVersionQuery()?
ensureVersionQuery() is called by 1 function(s): oxcResolvePlugin.

Analyze Your Own Codebase

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

Try Supermodel Free