Home / Function/ searchForWorkspaceRoot() — vite Function Reference

searchForWorkspaceRoot() — vite Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

packages/vite/src/node/server/searchRoot.ts lines 66–78

export function searchForWorkspaceRoot(
  current: string,
  root: string = searchForPackageRoot(current),
): string {
  if (hasRootFile(current)) return current
  if (hasWorkspacePackageJSON(current)) return current

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

  return searchForWorkspaceRoot(dir, root)
}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free