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

Function collect

packages/vite/src/node/plugins/css.ts:1015–1027  ·  view source on GitHub ↗
(chunk: OutputChunk | OutputAsset | undefined)

Source from the content-addressed store, hash-verified

1013 const dynamicImports = new Set<string>()
1014
1015 function collect(chunk: OutputChunk | OutputAsset | undefined) {
1016 if (!chunk || chunk.type !== 'chunk' || collected.has(chunk)) return
1017 collected.add(chunk)
1018
1019 // First collect all styles from the synchronous imports (lowest priority)
1020 chunk.imports.forEach((importName) => collect(bundle[importName]))
1021 // Save dynamic imports in deterministic order to add the styles later (to have the highest priority)
1022 chunk.dynamicImports.forEach((importName) =>
1023 dynamicImports.add(importName),
1024 )
1025 // Then collect the styles of the current chunk (might overwrite some styles from previous imports)
1026 extractedCss += chunkCSSMap.get(chunk.preliminaryFileName) ?? ''
1027 }
1028
1029 // The bundle is guaranteed to be deterministic, if not then we have a bug in rollup.
1030 // So we use it to ensure a deterministic order of styles

Callers 1

generateBundleFunction · 0.85

Calls 3

hasMethod · 0.80
addMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected