Home / Function/ isFilePathESM() — vite Function Reference

isFilePathESM() — vite Function Reference

Architecture documentation for the isFilePathESM() function in utils.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  a3a231c1_e1f6_f7c0_6d09_1d3c7fbf6ac6["isFilePathESM()"]
  031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"]
  a3a231c1_e1f6_f7c0_6d09_1d3c7fbf6ac6 -->|defined in| 031bc221_67a8_c579_f2bf_bb30a08beeb2
  de2a20c0_a4a2_f7c1_abd6_414c8a78818e["bundleAndLoadConfigFile()"]
  de2a20c0_a4a2_f7c1_abd6_414c8a78818e -->|calls| a3a231c1_e1f6_f7c0_6d09_1d3c7fbf6ac6
  a1fc1de5_905b_efe7_d960_3597604fbdfe["importAnalysisPlugin()"]
  a1fc1de5_905b_efe7_d960_3597604fbdfe -->|calls| a3a231c1_e1f6_f7c0_6d09_1d3c7fbf6ac6
  18626e4c_2392_d64e_6551_5d524a5d0253["fetchModule()"]
  18626e4c_2392_d64e_6551_5d524a5d0253 -->|calls| a3a231c1_e1f6_f7c0_6d09_1d3c7fbf6ac6
  31b651d6_9d57_14b0_2e8c_d85642bc19f4["findNearestPackageData()"]
  a3a231c1_e1f6_f7c0_6d09_1d3c7fbf6ac6 -->|calls| 31b651d6_9d57_14b0_2e8c_d85642bc19f4
  style a3a231c1_e1f6_f7c0_6d09_1d3c7fbf6ac6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/utils.ts lines 424–441

export function isFilePathESM(
  filePath: string,
  packageCache?: PackageCache,
): boolean {
  if (/\.m[jt]s$/.test(filePath)) {
    return true
  } else if (/\.c[jt]s$/.test(filePath)) {
    return false
  } else {
    // check package.json for type: "module"
    try {
      const pkg = findNearestPackageData(path.dirname(filePath), packageCache)
      return pkg?.data.type === 'module'
    } catch {
      return false
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does isFilePathESM() do?
isFilePathESM() is a function in the vite codebase, defined in packages/vite/src/node/utils.ts.
Where is isFilePathESM() defined?
isFilePathESM() is defined in packages/vite/src/node/utils.ts at line 424.
What does isFilePathESM() call?
isFilePathESM() calls 1 function(s): findNearestPackageData.
What calls isFilePathESM()?
isFilePathESM() is called by 3 function(s): bundleAndLoadConfigFile, fetchModule, importAnalysisPlugin.

Analyze Your Own Codebase

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

Try Supermodel Free