Home / Function/ searchForPackageRoot() — vite Function Reference

searchForPackageRoot() — vite Function Reference

Architecture documentation for the searchForPackageRoot() function in searchRoot.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  abbcb31f_2732_cc49_32a8_c121af61546c["searchForPackageRoot()"]
  497939be_63aa_81b3_3492_3f2698d33097["searchRoot.ts"]
  abbcb31f_2732_cc49_32a8_c121af61546c -->|defined in| 497939be_63aa_81b3_3492_3f2698d33097
  7bbcd1bc_4ca0_af2b_79c0_d079b5e5b839["resolveServerOptions()"]
  7bbcd1bc_4ca0_af2b_79c0_d079b5e5b839 -->|calls| abbcb31f_2732_cc49_32a8_c121af61546c
  f00607d5_f936_a7c7_9f17_a6349edeac83["searchForWorkspaceRoot()"]
  f00607d5_f936_a7c7_9f17_a6349edeac83 -->|calls| abbcb31f_2732_cc49_32a8_c121af61546c
  ca54fbf3_09b8_dc78_d456_909bca286809["hasPackageJSON()"]
  abbcb31f_2732_cc49_32a8_c121af61546c -->|calls| ca54fbf3_09b8_dc78_d456_909bca286809
  style abbcb31f_2732_cc49_32a8_c121af61546c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/searchRoot.ts lines 50–61

export function searchForPackageRoot(
  current: string,
  root: string = current,
): string {
  if (hasPackageJSON(current)) return current

  const dir = dirname(current)
  // reach the fs root
  if (!dir || dir === current) return root

  return searchForPackageRoot(dir, root)
}

Domain

Subdomains

Frequently Asked Questions

What does searchForPackageRoot() do?
searchForPackageRoot() is a function in the vite codebase, defined in packages/vite/src/node/server/searchRoot.ts.
Where is searchForPackageRoot() defined?
searchForPackageRoot() is defined in packages/vite/src/node/server/searchRoot.ts at line 50.
What does searchForPackageRoot() call?
searchForPackageRoot() calls 1 function(s): hasPackageJSON.
What calls searchForPackageRoot()?
searchForPackageRoot() is called by 2 function(s): resolveServerOptions, searchForWorkspaceRoot.

Analyze Your Own Codebase

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

Try Supermodel Free