mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
fix(modern): wrong assets mapping in ssr client modern mode (#7382)
This commit is contained in:
parent
ffb9c65f46
commit
b1b14033fb
@ -1,4 +1,3 @@
|
||||
import invert from 'lodash/invert'
|
||||
import { isUrl, urlJoin, safariNoModuleFix } from '@nuxt/utils'
|
||||
import SSRRenderer from './ssr'
|
||||
|
||||
@ -17,13 +16,15 @@ export default class ModernRenderer extends SSRRenderer {
|
||||
|
||||
const { clientManifest, modernManifest } = this.serverContext.resources
|
||||
const legacyAssets = clientManifest.assetsMapping
|
||||
const modernAssets = invert(modernManifest.assetsMapping)
|
||||
const modernAssets = modernManifest.assetsMapping
|
||||
const mapping = {}
|
||||
|
||||
for (const legacyJsFile in legacyAssets) {
|
||||
const chunkNamesHash = legacyAssets[legacyJsFile]
|
||||
mapping[legacyJsFile] = modernAssets[chunkNamesHash]
|
||||
}
|
||||
Object.keys(legacyAssets).forEach((componentHash) => {
|
||||
const modernComponentAssets = modernAssets[componentHash] || []
|
||||
legacyAssets[componentHash].forEach((legacyAssetName, index) => {
|
||||
mapping[legacyAssetName] = modernComponentAssets[index]
|
||||
})
|
||||
})
|
||||
delete clientManifest.assetsMapping
|
||||
delete modernManifest.assetsMapping
|
||||
this._assetsMapping = mapping
|
||||
|
@ -35,7 +35,11 @@ export default class VueSSRClientPlugin {
|
||||
stats.assets
|
||||
.filter(({ name }) => isJS(name))
|
||||
.forEach(({ name, chunkNames }) => {
|
||||
assetsMapping[name] = hash(chunkNames.join('|'))
|
||||
const componentHash = hash(chunkNames.join('|'))
|
||||
if (!assetsMapping[componentHash]) {
|
||||
assetsMapping[componentHash] = []
|
||||
}
|
||||
assetsMapping[componentHash].push(name)
|
||||
})
|
||||
|
||||
const manifest = {
|
||||
|
Loading…
Reference in New Issue
Block a user