From a37d8735d7aa234eaf9a254600ac7e3286f438e3 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Mon, 5 Oct 2015 08:45:43 -0700 Subject: [PATCH] Fix minified source maps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @​public The source maps generated by uglify are already stringified, and therefore were being stringified twice. Reviewed By: @martinbigio Differential Revision: D2498242 --- react-packager/src/Server/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index 74e83927..4fd0be57 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -361,9 +361,14 @@ class Server { res.end(bundleSource); Activity.endEvent(startReqEventId); } else if (requestType === 'map') { - var sourceMap = JSON.stringify(p.getSourceMap({ + var sourceMap = p.getSourceMap({ minify: options.minify, - })); + }); + + if (typeof sourceMap !== 'string') { + sourceMap = JSON.stringify(sourceMap); + } + res.setHeader('Content-Type', 'application/json'); res.end(sourceMap); Activity.endEvent(startReqEventId);