mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +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 { isUrl, urlJoin, safariNoModuleFix } from '@nuxt/utils'
|
||||||
import SSRRenderer from './ssr'
|
import SSRRenderer from './ssr'
|
||||||
|
|
||||||
@ -17,13 +16,15 @@ export default class ModernRenderer extends SSRRenderer {
|
|||||||
|
|
||||||
const { clientManifest, modernManifest } = this.serverContext.resources
|
const { clientManifest, modernManifest } = this.serverContext.resources
|
||||||
const legacyAssets = clientManifest.assetsMapping
|
const legacyAssets = clientManifest.assetsMapping
|
||||||
const modernAssets = invert(modernManifest.assetsMapping)
|
const modernAssets = modernManifest.assetsMapping
|
||||||
const mapping = {}
|
const mapping = {}
|
||||||
|
|
||||||
for (const legacyJsFile in legacyAssets) {
|
Object.keys(legacyAssets).forEach((componentHash) => {
|
||||||
const chunkNamesHash = legacyAssets[legacyJsFile]
|
const modernComponentAssets = modernAssets[componentHash] || []
|
||||||
mapping[legacyJsFile] = modernAssets[chunkNamesHash]
|
legacyAssets[componentHash].forEach((legacyAssetName, index) => {
|
||||||
}
|
mapping[legacyAssetName] = modernComponentAssets[index]
|
||||||
|
})
|
||||||
|
})
|
||||||
delete clientManifest.assetsMapping
|
delete clientManifest.assetsMapping
|
||||||
delete modernManifest.assetsMapping
|
delete modernManifest.assetsMapping
|
||||||
this._assetsMapping = mapping
|
this._assetsMapping = mapping
|
||||||
|
@ -35,7 +35,11 @@ export default class VueSSRClientPlugin {
|
|||||||
stats.assets
|
stats.assets
|
||||||
.filter(({ name }) => isJS(name))
|
.filter(({ name }) => isJS(name))
|
||||||
.forEach(({ name, chunkNames }) => {
|
.forEach(({ name, chunkNames }) => {
|
||||||
assetsMapping[name] = hash(chunkNames.join('|'))
|
const componentHash = hash(chunkNames.join('|'))
|
||||||
|
if (!assetsMapping[componentHash]) {
|
||||||
|
assetsMapping[componentHash] = []
|
||||||
|
}
|
||||||
|
assetsMapping[componentHash].push(name)
|
||||||
})
|
})
|
||||||
|
|
||||||
const manifest = {
|
const manifest = {
|
||||||
|
Loading…
Reference in New Issue
Block a user