diff --git a/local-cli/server/middleware/heapCaptureMiddleware.js b/local-cli/server/middleware/heapCaptureMiddleware.js index cf98f819f..02b4f0a8d 100644 --- a/local-cli/server/middleware/heapCaptureMiddleware.js +++ b/local-cli/server/middleware/heapCaptureMiddleware.js @@ -32,10 +32,11 @@ function getSourceMapForUrl(url, onFailure, onSuccess) { } const parsedUrl = urlLib.parse(url); + const mapPath = parsedUrl.pathname.replace(/\.bundle$/, '.map'); const options = { host: 'localhost', port: parsedUrl.port, - path: parsedUrl.pathname.replace(/\.bundle$/, '.map') + parsedUrl.search, + path: mapPath + parsedUrl.search + '&babelSourcemap=true', }; http.get(options, (res) => { diff --git a/local-cli/server/middleware/jscProfilerMiddleware.js b/local-cli/server/middleware/jscProfilerMiddleware.js index e2d6db9c3..657e57dcf 100644 --- a/local-cli/server/middleware/jscProfilerMiddleware.js +++ b/local-cli/server/middleware/jscProfilerMiddleware.js @@ -79,10 +79,11 @@ class TreeTransformator { } const parsedUrl = urlLib.parse(url); + const mapPath = parsedUrl.pathname.replace(/\.bundle$/, '.map'); const options = { host: 'localhost', port: parsedUrl.port, - path: parsedUrl.pathname.replace(/\.bundle$/, '.map') + parsedUrl.search, + path: mapPath + parsedUrl.search + '&babelSourcemap=true', }; http.get(options, (res) => { diff --git a/packager/react-packager/src/Bundler/index.js b/packager/react-packager/src/Bundler/index.js index 20993e4b5..2d640dae3 100644 --- a/packager/react-packager/src/Bundler/index.js +++ b/packager/react-packager/src/Bundler/index.js @@ -257,6 +257,7 @@ class Bundler { entryModuleOnly, resolutionResponse, isolateModuleIDs, + generateSourceMaps, }) { const onResolutionResponse = response => { bundle.setMainModuleId(response.getModuleId(getMainModule(response))); @@ -301,6 +302,7 @@ class Bundler { onResolutionResponse, finalizeBundle, isolateModuleIDs, + generateSourceMaps, }); } @@ -352,6 +354,7 @@ class Bundler { unbundle, resolutionResponse, isolateModuleIDs, + generateSourceMaps, onResolutionResponse = noop, onModuleTransformed = noop, finalizeBundle = noop, @@ -385,7 +388,7 @@ class Bundler { onProgress, minify, isolateModuleIDs, - generateSourceMaps: unbundle, + generateSourceMaps: unbundle || generateSourceMaps, }); } diff --git a/packager/react-packager/src/Server/index.js b/packager/react-packager/src/Server/index.js index 54ef2b1bd..08576bbb7 100644 --- a/packager/react-packager/src/Server/index.js +++ b/packager/react-packager/src/Server/index.js @@ -150,6 +150,10 @@ const bundleOpts = declareOpts({ resolutionResponse: { type: 'object', }, + generateSourceMaps: { + type: 'boolean', + required: false, + } }); const dependencyOpts = declareOpts({ @@ -814,7 +818,7 @@ class Server { sourceMapUrl: url.format(sourceMapUrlObj), entryFile: entryFile, dev: this._getBoolOptionFromQuery(urlObj.query, 'dev', true), - minify: this._getBoolOptionFromQuery(urlObj.query, 'minify'), + minify: this._getBoolOptionFromQuery(urlObj.query, 'minify', false), hot: this._getBoolOptionFromQuery(urlObj.query, 'hot', false), runModule: this._getBoolOptionFromQuery(urlObj.query, 'runModule', true), inlineSourceMap: this._getBoolOptionFromQuery( @@ -828,11 +832,12 @@ class Server { 'entryModuleOnly', false, ), + generateSourceMaps: this._getBoolOptionFromQuery(urlObj.query, 'babelSourcemap'), }; } _getBoolOptionFromQuery(query, opt, defaultVal) { - if (query[opt] == null && defaultVal != null) { + if (query[opt] == null) { return defaultVal; }