From d929cd4ef6bf10a12194ed9b2d2a6204e7c8e1be Mon Sep 17 00:00:00 2001 From: Michael Brevard Date: Thu, 13 Jun 2024 21:56:26 +0100 Subject: [PATCH] perf(webpack): decrease assets map iterations --- packages/webpack/src/plugins/vue/client.ts | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/webpack/src/plugins/vue/client.ts b/packages/webpack/src/plugins/vue/client.ts index 14c0c184e3..10127fcace 100644 --- a/packages/webpack/src/plugins/vue/client.ts +++ b/packages/webpack/src/plugins/vue/client.ts @@ -43,24 +43,19 @@ export default class VueSSRClientPlugin { const allFiles = new Set() const asyncFiles = new Set() - - for (const asset of stats.assets!) { - const file = asset.name - if (!isHotUpdate(file)) { - allFiles.add(file) - if (initialFiles.has(file)) { continue } - if (isJS(file) || isCSS(file)) { - asyncFiles.add(file) - } - } - } - const assetsMapping: Record = {} - for (const { name, chunkNames = [] } of stats.assets!) { - if (isJS(name) && !isHotUpdate(name)) { + + for (const { name: file, chunkNames = [] } of stats.assets!) { + if (isHotUpdate(file)) { continue } + allFiles.add(file) + const isFileJS = isJS(file) + if (!initialFiles.has(file) && (isFileJS || isCSS(file))) { + asyncFiles.add(file) + } + if (isFileJS) { const componentHash = hash(chunkNames.join('|')) const map = assetsMapping[componentHash] ||= [] - map.push(name) + map.push(file) } }