Skip to content

Commit

Permalink
fix(renderer): ignore invalid sourcemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 1, 2018
1 parent c0721c0 commit 4b643b9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/vue-renderer/src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,23 +389,31 @@ export default class VueRenderer {
transform: (src, { readResource, oldValue = { files: {}, maps: {} } }) => {
const serverManifest = JSON.parse(src)

const resolveAssets = (obj, oldObj, isJSON) => {
const resolveAssets = (obj, oldObj) => {
Object.keys(obj).forEach((name) => {
obj[name] = readResource(obj[name])
// Try to reuse deleted MFS files if no new version exists
if (!obj[name]) {
obj[name] = oldObj[name]
}
// Parse JSON
if (isJSON) {
obj[name] = JSON.parse(obj[name])
}
})
return obj
}

const files = resolveAssets(serverManifest.files, oldValue.files)
const maps = resolveAssets(serverManifest.maps, oldValue.maps, true)
const maps = resolveAssets(serverManifest.maps, oldValue.maps)

// Try to parse sourcemaps
for (const map in maps) {
if (maps[map] && maps[map].version) {
continue
}
try {
maps[map] = JSON.parse(maps[map])
} catch (e) {
maps[map] = { version: 3, sources: [], mappings: '' }
}
}

return {
...serverManifest,
Expand Down

0 comments on commit 4b643b9

Please sign in to comment.