Home / Function/ mapWithBrowserField() — vite Function Reference

mapWithBrowserField() — vite Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8ff08c93_2e0c_c3ed_bfd0_267a77f07273["mapWithBrowserField()"]
  dcff87b0_a8ea_57a2_3b29_a7b8f19986f3["resolve.ts"]
  8ff08c93_2e0c_c3ed_bfd0_267a77f07273 -->|defined in| dcff87b0_a8ea_57a2_3b29_a7b8f19986f3
  ff420344_db87_ddaa_de80_eb7cf9a4644d["resolvePackageEntry()"]
  ff420344_db87_ddaa_de80_eb7cf9a4644d -->|calls| 8ff08c93_2e0c_c3ed_bfd0_267a77f07273
  b2e6fca1_a66d_30a7_9a9e_9c6de6c46d25["resolveDeepImport()"]
  b2e6fca1_a66d_30a7_9a9e_9c6de6c46d25 -->|calls| 8ff08c93_2e0c_c3ed_bfd0_267a77f07273
  251e65d5_721b_49e6_292d_16474dee6a4a["equalWithoutSuffix()"]
  8ff08c93_2e0c_c3ed_bfd0_267a77f07273 -->|calls| 251e65d5_721b_49e6_292d_16474dee6a4a
  style 8ff08c93_2e0c_c3ed_bfd0_267a77f07273 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/resolve.ts lines 1166–1182

function mapWithBrowserField(
  relativePathInPkgDir: string,
  map: Record<string, string | false>,
): string | false | undefined {
  const normalizedPath = path.posix.normalize(relativePathInPkgDir)

  for (const key in map) {
    const normalizedKey = path.posix.normalize(key)
    if (
      normalizedPath === normalizedKey ||
      equalWithoutSuffix(normalizedPath, normalizedKey, '.js') ||
      equalWithoutSuffix(normalizedPath, normalizedKey, '/index.js')
    ) {
      return map[key]
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does mapWithBrowserField() do?
mapWithBrowserField() is a function in the vite codebase, defined in packages/vite/src/node/plugins/resolve.ts.
Where is mapWithBrowserField() defined?
mapWithBrowserField() is defined in packages/vite/src/node/plugins/resolve.ts at line 1166.
What does mapWithBrowserField() call?
mapWithBrowserField() calls 1 function(s): equalWithoutSuffix.
What calls mapWithBrowserField()?
mapWithBrowserField() is called by 2 function(s): resolveDeepImport, resolvePackageEntry.

Analyze Your Own Codebase

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

Try Supermodel Free