perf(webpack): decrease assets map iterations

This commit is contained in:
Michael Brevard 2024-06-13 21:56:26 +01:00
parent e4bfea6428
commit d929cd4ef6

View File

@ -43,24 +43,19 @@ export default class VueSSRClientPlugin {
const allFiles = new Set<string>() const allFiles = new Set<string>()
const asyncFiles = new Set<string>() const asyncFiles = new Set<string>()
const assetsMapping: Record<string, string[]> = {}
for (const asset of stats.assets!) { for (const { name: file, chunkNames = [] } of stats.assets!) {
const file = asset.name if (isHotUpdate(file)) { continue }
if (!isHotUpdate(file)) {
allFiles.add(file) allFiles.add(file)
if (initialFiles.has(file)) { continue } const isFileJS = isJS(file)
if (isJS(file) || isCSS(file)) { if (!initialFiles.has(file) && (isFileJS || isCSS(file))) {
asyncFiles.add(file) asyncFiles.add(file)
} }
} if (isFileJS) {
}
const assetsMapping: Record<string, string[]> = {}
for (const { name, chunkNames = [] } of stats.assets!) {
if (isJS(name) && !isHotUpdate(name)) {
const componentHash = hash(chunkNames.join('|')) const componentHash = hash(chunkNames.join('|'))
const map = assetsMapping[componentHash] ||= [] const map = assetsMapping[componentHash] ||= []
map.push(name) map.push(file)
} }
} }