feat(ssr): add non async split chunk to preload scripts (#7383)

This commit is contained in:
Xin Du (Clark) 2020-05-17 20:39:17 +01:00 committed by GitHub
parent f4f6b1912b
commit ffb9c65f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,7 @@ export default class VueSSRClientPlugin {
assetsMapping assetsMapping
} }
const { entrypoints, namedChunkGroups } = stats
const assetModules = stats.modules.filter(m => m.assets.length) const assetModules = stats.modules.filter(m => m.assets.length)
const fileToIndex = file => manifest.all.indexOf(file) const fileToIndex = file => manifest.all.indexOf(file)
stats.modules.forEach((m) => { stats.modules.forEach((m) => {
@ -58,7 +59,21 @@ export default class VueSSRClientPlugin {
return return
} }
const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash
const files = manifest.modules[hash(id)] = chunk.files.map(fileToIndex) const filesSet = new Set(chunk.files.map(fileToIndex))
for (const chunkName of chunk.names) {
if (!entrypoints[chunkName]) {
const chunkGroup = namedChunkGroups[chunkName]
if (chunkGroup) {
for (const asset of chunkGroup.assets) {
filesSet.add(fileToIndex(asset))
}
}
}
}
const files = Array.from(filesSet)
manifest.modules[hash(id)] = files
// In production mode, modules may be concatenated by scope hoisting // In production mode, modules may be concatenated by scope hoisting
// Include ConcatenatedModule for not losing module-component mapping // Include ConcatenatedModule for not losing module-component mapping