Home / Function/ validateChunkImports() — vite Function Reference

validateChunkImports() — vite Function Reference

Architecture documentation for the validateChunkImports() function in rolldown.dts.config.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  7fb0a4e1_17c2_cac8_8cae_6035efcfec74["validateChunkImports()"]
  c2239521_b59e_589c_03c3_99028d5442bd["rolldown.dts.config.ts"]
  7fb0a4e1_17c2_cac8_8cae_6035efcfec74 -->|defined in| c2239521_b59e_589c_03c3_99028d5442bd
  style 7fb0a4e1_17c2_cac8_8cae_6035efcfec74 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/rolldown.dts.config.ts lines 234–261

function validateChunkImports(
  this: PluginContext,
  chunk: RenderedChunk,
  importBindings: ImportBindings[],
) {
  const deps = Object.keys(pkg.dependencies)
  for (const { id, bindings } of importBindings) {
    if (
      !id.startsWith('./') &&
      !id.startsWith('../') &&
      !id.startsWith('#') &&
      !id.startsWith('node:') &&
      !id.startsWith('types.d') &&
      !id.startsWith('vite/') &&
      // index and moduleRunner have a common chunk
      !id.startsWith('chunks/') &&
      !deps.includes(id) &&
      !deps.some((name) => id.startsWith(name + '/'))
    ) {
      // If validation failed, only warn and set exit code 1 so that files
      // are written to disk for inspection, but the build will fail
      this.warn(
        `${chunk.fileName} imports "${bindings.join(', ')}" from "${id}" which is not allowed`,
      )
      process.exitCode = 1
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does validateChunkImports() do?
validateChunkImports() is a function in the vite codebase, defined in packages/vite/rolldown.dts.config.ts.
Where is validateChunkImports() defined?
validateChunkImports() is defined in packages/vite/rolldown.dts.config.ts at line 234.

Analyze Your Own Codebase

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

Try Supermodel Free