mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix(vue-renderer): parse JSON values before passing to bundle-renderer
prevent error that occuers in rare cases: TypeError: Cannot read property 'sections' of undefined Related to #4439
This commit is contained in:
parent
0f104aa588
commit
c0721c0174
@ -389,19 +389,23 @@ export default class VueRenderer {
|
|||||||
transform: (src, { readResource, oldValue = { files: {}, maps: {} } }) => {
|
transform: (src, { readResource, oldValue = { files: {}, maps: {} } }) => {
|
||||||
const serverManifest = JSON.parse(src)
|
const serverManifest = JSON.parse(src)
|
||||||
|
|
||||||
const resolveAssets = (obj, oldObj, encoding) => {
|
const resolveAssets = (obj, oldObj, isJSON) => {
|
||||||
Object.keys(obj).forEach((name) => {
|
Object.keys(obj).forEach((name) => {
|
||||||
obj[name] = readResource(obj[name], encoding)
|
obj[name] = readResource(obj[name])
|
||||||
// Try to reuse deleted MFS files if no new version exists
|
// Try to reuse deleted MFS files if no new version exists
|
||||||
if (!obj[name]) {
|
if (!obj[name]) {
|
||||||
obj[name] = oldObj[name]
|
obj[name] = oldObj[name]
|
||||||
}
|
}
|
||||||
|
// Parse JSON
|
||||||
|
if (isJSON) {
|
||||||
|
obj[name] = JSON.parse(obj[name])
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = resolveAssets(serverManifest.files, oldValue.files)
|
const files = resolveAssets(serverManifest.files, oldValue.files)
|
||||||
const maps = resolveAssets(serverManifest.maps, oldValue.maps, 'utf-8')
|
const maps = resolveAssets(serverManifest.maps, oldValue.maps, true)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...serverManifest,
|
...serverManifest,
|
||||||
|
Loading…
Reference in New Issue
Block a user