Home / Function/ createParseErrorInfo() — vite Function Reference

createParseErrorInfo() — vite Function Reference

Architecture documentation for the createParseErrorInfo() function in importAnalysis.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  1976bcb9_a492_4760_b3a8_ad9296c5c6ba["createParseErrorInfo()"]
  5a7b98e4_4eb1_dfca_508b_2d43e2a077e6["importAnalysis.ts"]
  1976bcb9_a492_4760_b3a8_ad9296c5c6ba -->|defined in| 5a7b98e4_4eb1_dfca_508b_2d43e2a077e6
  a1fc1de5_905b_efe7_d960_3597604fbdfe["importAnalysisPlugin()"]
  a1fc1de5_905b_efe7_d960_3597604fbdfe -->|calls| 1976bcb9_a492_4760_b3a8_ad9296c5c6ba
  339d40b3_de1a_5feb_2d6a_c19f0aafdfe2["isJSRequest()"]
  1976bcb9_a492_4760_b3a8_ad9296c5c6ba -->|calls| 339d40b3_de1a_5feb_2d6a_c19f0aafdfe2
  style 1976bcb9_a492_4760_b3a8_ad9296c5c6ba fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/importAnalysis.ts lines 883–913

export function createParseErrorInfo(
  importer: string,
  source: string,
): { message: string; showCodeFrame: boolean } {
  const isVue = importer.endsWith('.vue')
  const isJsx = importer.endsWith('.jsx') || importer.endsWith('.tsx')
  const maybeJSX = !isVue && isJSRequest(importer)
  const probablyBinary = source.includes(
    '\ufffd' /* unicode replacement character */,
  )

  const msg = isVue
    ? `Install @vitejs/plugin-vue to handle .vue files.`
    : maybeJSX
      ? isJsx
        ? `If you use tsconfig.json, make sure to not set jsx to preserve.`
        : `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
      : `You may need to install appropriate plugins to handle the ${path.extname(
          importer,
        )} file format, or if it's an asset, add "**/*${path.extname(
          importer,
        )}" to \`assetsInclude\` in your configuration.`

  return {
    message:
      `Failed to parse source for import analysis because the content ` +
      `contains invalid JS syntax. ` +
      msg,
    showCodeFrame: !probablyBinary,
  }
}

Domain

Subdomains

Frequently Asked Questions

What does createParseErrorInfo() do?
createParseErrorInfo() is a function in the vite codebase, defined in packages/vite/src/node/plugins/importAnalysis.ts.
Where is createParseErrorInfo() defined?
createParseErrorInfo() is defined in packages/vite/src/node/plugins/importAnalysis.ts at line 883.
What does createParseErrorInfo() call?
createParseErrorInfo() calls 1 function(s): isJSRequest.
What calls createParseErrorInfo()?
createParseErrorInfo() is called by 1 function(s): importAnalysisPlugin.

Analyze Your Own Codebase

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

Try Supermodel Free