Skip to content

Commit d929cd4

Browse files
perf(webpack): decrease assets map iterations
1 parent e4bfea6 commit d929cd4

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

packages/webpack/src/plugins/vue/client.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,19 @@ export default class VueSSRClientPlugin {
4343

4444
const allFiles = new Set<string>()
4545
const asyncFiles = new Set<string>()
46+
const assetsMapping: Record<string, string[]> = {}
4647

47-
for (const asset of stats.assets!) {
48-
const file = asset.name
49-
if (!isHotUpdate(file)) {
50-
allFiles.add(file)
51-
if (initialFiles.has(file)) { continue }
52-
if (isJS(file) || isCSS(file)) {
53-
asyncFiles.add(file)
54-
}
48+
for (const { name: file, chunkNames = [] } of stats.assets!) {
49+
if (isHotUpdate(file)) { continue }
50+
allFiles.add(file)
51+
const isFileJS = isJS(file)
52+
if (!initialFiles.has(file) && (isFileJS || isCSS(file))) {
53+
asyncFiles.add(file)
5554
}
56-
}
57-
58-
const assetsMapping: Record<string, string[]> = {}
59-
for (const { name, chunkNames = [] } of stats.assets!) {
60-
if (isJS(name) && !isHotUpdate(name)) {
55+
if (isFileJS) {
6156
const componentHash = hash(chunkNames.join('|'))
6257
const map = assetsMapping[componentHash] ||= []
63-
map.push(name)
58+
map.push(file)
6459
}
6560
}
6661

0 commit comments

Comments
 (0)