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

Function renderChunk

packages/vite/src/node/plugins/esbuild.ts:394–423  ·  view source on GitHub ↗
(code, chunk, opts)

Source from the content-addressed store, hash-verified

392 return environment.config.esbuild !== false
393 },
394 async renderChunk(code, chunk, opts) {
395 // avoid on legacy chunks since it produces legacy-unsafe code
396 // e.g. rewriting object properties into shorthands
397 if (this.environment.config.isOutputOptionsForLegacyChunks?.(opts)) {
398 return null
399 }
400
401 const config = this.environment.config
402 const options = resolveEsbuildTranspileOptions(config, opts.format)
403
404 if (!options) {
405 return null
406 }
407
408 const res = await transformWithEsbuild(
409 code,
410 chunk.fileName,
411 options,
412 undefined,
413 config,
414 undefined,
415 true,
416 )
417
418 if (config.build.lib) {
419 res.code = injectEsbuildHelpers(res.code, opts.format)
420 }
421
422 return res
423 },
424 }
425}
426

Callers

nothing calls this directly

Calls 3

transformWithEsbuildFunction · 0.85
injectEsbuildHelpersFunction · 0.85

Tested by

no test coverage detected