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

Function getImportedChunks

packages/vite/src/node/plugins/html.ts:827–848  ·  view source on GitHub ↗
(
        chunk: OutputChunk,
        seen: Set<string> = new Set(),
      )

Source from the content-addressed store, hash-verified

825 const analyzedImportedCssFiles = new Map<OutputChunk, string[]>()
826 const inlineEntryChunk = new Set<string>()
827 const getImportedChunks = (
828 chunk: OutputChunk,
829 seen: Set<string> = new Set(),
830 ): (OutputChunk | string)[] => {
831 const chunks: (OutputChunk | string)[] = []
832 chunk.imports.forEach((file) => {
833 const importee = bundle[file]
834 if (importee) {
835 if (importee.type === 'chunk' && !seen.has(file)) {
836 seen.add(file)
837
838 // post-order traversal
839 chunks.push(...getImportedChunks(importee, seen))
840 chunks.push(importee)
841 }
842 } else {
843 // external imports
844 chunks.push(file)
845 }
846 })
847 return chunks
848 }
849
850 const toScriptTag = (
851 chunkOrUrl: OutputChunk | string,

Callers 1

generateBundleFunction · 0.85

Calls 2

hasMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected