mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
perf(webpack): decrease assets map iterations
This commit is contained in:
parent
e4bfea6428
commit
d929cd4ef6
@ -43,24 +43,19 @@ export default class VueSSRClientPlugin {
|
||||
|
||||
const allFiles = new Set<string>()
|
||||
const asyncFiles = new Set<string>()
|
||||
|
||||
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<string, string[]> = {}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user