1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Do not mutate browser source map object (#2900)

Fixes regression caused by #2478
This commit is contained in:
Kevin Decker 2017-09-04 13:27:19 -05:00 committed by Tim Neutkens
parent e13bb3f62f
commit 5c67fd6811

View file

@ -252,13 +252,14 @@ export default async function createCompiler (dir, { buildId, dev = false, quiet
let output = transpiled.code
if (map) {
map.sources = map.sources.map((source) => source.replace(/\?entry/, ''))
delete map.sourcesContent
let nodeMap = Object.assign({}, map)
nodeMap.sources = nodeMap.sources.map((source) => source.replace(/\?entry/, ''))
delete nodeMap.sourcesContent
// Output explicit inline source map that source-map-support can pickup via requireHook mode.
// Since these are not formal chunks, the devtool infrastructure in webpack does not output
// a source map for these files.
const sourceMapUrl = new Buffer(JSON.stringify(map), 'utf-8').toString('base64')
const sourceMapUrl = new Buffer(JSON.stringify(nodeMap), 'utf-8').toString('base64')
output = `${output}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${sourceMapUrl}`
}