From 5c67fd681167700d02ee85c366ee9bbc740f615c Mon Sep 17 00:00:00 2001 From: Kevin Decker Date: Mon, 4 Sep 2017 13:27:19 -0500 Subject: [PATCH] Do not mutate browser source map object (#2900) Fixes regression caused by #2478 --- server/build/webpack.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/build/webpack.js b/server/build/webpack.js index eb743758..3422cbf7 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -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}` }