From d6e80c4ebf1cd8d4ff462f370c85cb05b224d03e Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Mon, 5 Feb 2018 00:59:34 -0800 Subject: [PATCH] When the sourceMap option is false, try to listen to it better Summary: I think the default value for the `--source-map` option is true, although it's not defined that way explicitly. Regardless, when it's explicitly set to `false` I would expect Metro to at least listen to that. Currently that's not the case. This diff attempts to improve that situation. Note that it's still not perfect since there are more places where sourcemaps are still being touched when this flag is `false`. It turns out adding a proper flag for this leads to a lot of cascading type problems and so I ended up with this fix instead. Reviewed By: rafeca Differential Revision: D6884423 fbshipit-source-id: 7fe10045d9d9f73c7841588627ba41b14c2e412b --- packages/metro/src/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/metro/src/index.js b/packages/metro/src/index.js index 8838d76a..02ca6459 100644 --- a/packages/metro/src/index.js +++ b/packages/metro/src/index.js @@ -289,7 +289,8 @@ exports.runBuild = async (options: RunBuildOptions) => { inlineSourceMap: options.sourceMap && !!options.sourceMapUrl, minify: options.optimize || false, platform: options.platform || `web`, - sourceMapUrl: options.sourceMapUrl, + sourceMapUrl: + options.sourceMap === false ? undefined : options.sourceMapUrl, createModuleIdFactory: options.config ? options.config.createModuleIdFactory : undefined, @@ -299,7 +300,10 @@ exports.runBuild = async (options: RunBuildOptions) => { const outputOptions: OutputOptions = { bundleOutput: options.out.replace(/(\.js)?$/, '.js'), - sourcemapOutput: options.out.replace(/(\.js)?$/, '.map'), + sourcemapOutput: + options.sourceMap === false + ? undefined + : options.out.replace(/(\.js)?$/, '.map'), dev: options.dev, platform: options.platform || `web`, };