MCPcopy
hub / github.com/vitejs/vite / validateRunnerChunk

Function validateRunnerChunk

packages/vite/rolldown.dts.config.ts:209–229  ·  view source on GitHub ↗

* Runner chunk should only import local dependencies to stay lightweight

(
  this: PluginContext,
  chunk: RenderedChunk,
  importBindings: ImportBindings[],
)

Source from the content-addressed store, hash-verified

207 * Runner chunk should only import local dependencies to stay lightweight
208 */
209function validateRunnerChunk(
210 this: PluginContext,
211 chunk: RenderedChunk,
212 importBindings: ImportBindings[],
213) {
214 for (const { id, bindings } of importBindings) {
215 if (
216 !id.startsWith('./') &&
217 !id.startsWith('../') &&
218 !id.startsWith('#') &&
219 // index and moduleRunner have a common chunk
220 !id.startsWith('chunks/') &&
221 !id.startsWith('types.d')
222 ) {
223 this.warn(
224 `${chunk.fileName} imports "${bindings.join(', ')}" from "${id}" which is not allowed`,
225 )
226 process.exitCode = 1
227 }
228 }
229}
230
231/**
232 * Validate that chunk imports do not import dev deps

Callers

nothing calls this directly

Calls 1

warnMethod · 0.65

Tested by

no test coverage detected