Permalink
Browse files

Make preset a function to account for different dev settings

Summary: Makes `babel-preset-react-native` a factory function that allows to include/exclude dev tool transforms per transform.

Reviewed By: jeanlauliac

Differential Revision: D5237158

fbshipit-source-id: aa7be0fc0f471575b4ee1c5a0e266e2ed2477fc6
  • Loading branch information...
davidaurelio authored and facebook-github-bot committed Jun 14, 2017
1 parent 5c57601 commit bc22a4da7ea74d17cd701717268c8e50f001d614
Showing with 15 additions and 9 deletions.
  1. +14 −8 babel-preset/configs/main.js
  2. +1 −1 babel-preset/package.json
@@ -10,7 +10,7 @@
var resolvePlugins = require('../lib/resolvePlugins');
var preset = {
var base = {
comments: false,
compact: true,
plugins: resolvePlugins([
@@ -42,11 +42,17 @@ var preset = {
]),
};
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
if (!env || env === 'development') {
preset.plugins = preset.plugins.concat(
resolvePlugins(['transform-react-jsx-source'])
);
}
var devTools = Object.assign({}, base);
devTools.plugins = devTools.plugins.concat(
resolvePlugins(['transform-react-jsx-source'])
);
module.exports = preset;
module.exports = function(options) {
var withDevTools = options.withDevTools;
if (withDevTools == null) {
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
withDevTools = !env || env === 'development';
}
return withDevTools ? devTools : base;
};
@@ -1,6 +1,6 @@
{
"name": "babel-preset-react-native",
"version": "2.0.0-alpha.1",
"version": "2.0.0",
"description": "Babel preset for React Native applications",
"main": "index.js",
"repository": "https://github.com/facebook/react-native/tree/master/babel-preset",

0 comments on commit bc22a4d

Please sign in to comment.