From 4d38af7448a15bb08808ec0797470e1caf571447 Mon Sep 17 00:00:00 2001 From: Angly Cat Date: Mon, 25 Feb 2019 13:24:19 +0600 Subject: [PATCH] Allow custom BABEL_ENV --- packages/metro-babel-transformer/src/index.js | 4 +++- packages/metro-react-native-babel-transformer/src/index.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/metro-babel-transformer/src/index.js b/packages/metro-babel-transformer/src/index.js index 58dfa4f73b..fb01801fdf 100644 --- a/packages/metro-babel-transformer/src/index.js +++ b/packages/metro-babel-transformer/src/index.js @@ -44,7 +44,9 @@ export type BabelTransformer = {| function transform({filename, options, plugins, src}: BabelTransformerArgs) { const OLD_BABEL_ENV = process.env.BABEL_ENV; - process.env.BABEL_ENV = options.dev ? 'development' : 'production'; + process.env.BABEL_ENV = options.dev + ? 'development' + : process.env.BABEL_ENV || 'production'; try { const {ast} = transformSync(src, { diff --git a/packages/metro-react-native-babel-transformer/src/index.js b/packages/metro-react-native-babel-transformer/src/index.js index d60564f754..d5df2c8c69 100644 --- a/packages/metro-react-native-babel-transformer/src/index.js +++ b/packages/metro-react-native-babel-transformer/src/index.js @@ -141,7 +141,9 @@ function buildBabelConfig(filename, options, plugins?: BabelPlugins = []) { function transform({filename, options, src, plugins}: BabelTransformerArgs) { const OLD_BABEL_ENV = process.env.BABEL_ENV; - process.env.BABEL_ENV = options.dev ? 'development' : 'production'; + process.env.BABEL_ENV = options.dev + ? 'development' + : process.env.BABEL_ENV || 'production'; try { const babelConfig = buildBabelConfig(filename, options, plugins);