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

Function generateBundle

packages/vite/src/node/plugins/worker.ts:632–664  ·  view source on GitHub ↗
(opts, bundle)

Source from the content-addressed store, hash-verified

630 : {}),
631
632 generateBundle(opts, bundle) {
633 // to avoid emitting duplicate assets for modern build and legacy build
634 if (
635 this.environment.config.isOutputOptionsForLegacyChunks?.(opts) ||
636 isWorker
637 ) {
638 return
639 }
640 for (const asset of workerOutputCaches.get(config)!.getAssets()) {
641 if (emittedAssets.has(asset.fileName)) continue
642 emittedAssets.add(asset.fileName)
643
644 const duplicateAsset = bundle[asset.fileName]
645 if (duplicateAsset) {
646 const content =
647 duplicateAsset.type === 'asset'
648 ? duplicateAsset.source
649 : duplicateAsset.code
650 // don't emit if the file name and the content is same
651 if (isSameContent(content, asset.source)) {
652 continue
653 }
654 }
655
656 this.emitFile({
657 type: 'asset',
658 fileName: asset.fileName,
659 source: asset.source,
660 // NOTE: fileName is already generated when bundling the worker
661 // so no need to pass originalFileNames/names
662 })
663 }
664 },
665
666 watchChange(file) {
667 if (isWorker) return

Callers

nothing calls this directly

Calls 6

isSameContentFunction · 0.85
getAssetsMethod · 0.80
hasMethod · 0.80
addMethod · 0.80
emitFileMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected