Home / Function/ discoverProjectDependencies() — vite Function Reference

discoverProjectDependencies() — vite Function Reference

Architecture documentation for the discoverProjectDependencies() function in index.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  fca4ce05_45e4_28a5_7b84_fc3f5cbc24bb["discoverProjectDependencies()"]
  2f328851_91ee_fb05_63f0_4f466b9d6250["index.ts"]
  fca4ce05_45e4_28a5_7b84_fc3f5cbc24bb -->|defined in| 2f328851_91ee_fb05_63f0_4f466b9d6250
  d04f1f71_b435_f5c3_dc33_d847fd576eaf["optimizeDeps()"]
  d04f1f71_b435_f5c3_dc33_d847fd576eaf -->|calls| fca4ce05_45e4_28a5_7b84_fc3f5cbc24bb
  d40c38f0_b6c1_b93f_a735_b3f1e17bea5b["createDepsOptimizer()"]
  d40c38f0_b6c1_b93f_a735_b3f1e17bea5b -->|calls| fca4ce05_45e4_28a5_7b84_fc3f5cbc24bb
  ca966b07_32a3_9d37_9eca_d2ebd25f7f76["scanImports()"]
  fca4ce05_45e4_28a5_7b84_fc3f5cbc24bb -->|calls| ca966b07_32a3_9d37_9eca_d2ebd25f7f76
  style fca4ce05_45e4_28a5_7b84_fc3f5cbc24bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/optimizer/index.ts lines 451–477

export function discoverProjectDependencies(environment: ScanEnvironment): {
  cancel: () => Promise<void>
  result: Promise<Record<string, string>>
} {
  const { cancel, result } = scanImports(environment)

  return {
    cancel,
    result: result.then(({ deps, missing }) => {
      const missingIds = Object.keys(missing)
      if (missingIds.length) {
        throw new Error(
          `The following dependencies are imported but could not be resolved:\n\n  ${missingIds
            .map(
              (id) =>
                `${colors.cyan(id)} ${colors.white(
                  colors.dim(`(imported by ${missing[id]})`),
                )}`,
            )
            .join(`\n  `)}\n\nAre they installed?`,
        )
      }

      return deps
    }),
  }
}

Subdomains

Frequently Asked Questions

What does discoverProjectDependencies() do?
discoverProjectDependencies() is a function in the vite codebase, defined in packages/vite/src/node/optimizer/index.ts.
Where is discoverProjectDependencies() defined?
discoverProjectDependencies() is defined in packages/vite/src/node/optimizer/index.ts at line 451.
What does discoverProjectDependencies() call?
discoverProjectDependencies() calls 1 function(s): scanImports.
What calls discoverProjectDependencies()?
discoverProjectDependencies() is called by 2 function(s): createDepsOptimizer, optimizeDeps.

Analyze Your Own Codebase

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

Try Supermodel Free