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
This commit is contained in:
parent
5c57601769
commit
bc22a4da7e
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
var resolvePlugins = require('../lib/resolvePlugins');
|
var resolvePlugins = require('../lib/resolvePlugins');
|
||||||
|
|
||||||
var preset = {
|
var base = {
|
||||||
comments: false,
|
comments: false,
|
||||||
compact: true,
|
compact: true,
|
||||||
plugins: resolvePlugins([
|
plugins: resolvePlugins([
|
||||||
|
@ -42,11 +42,17 @@ var preset = {
|
||||||
]),
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
|
var devTools = Object.assign({}, base);
|
||||||
if (!env || env === 'development') {
|
devTools.plugins = devTools.plugins.concat(
|
||||||
preset.plugins = preset.plugins.concat(
|
|
||||||
resolvePlugins(['transform-react-jsx-source'])
|
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",
|
"name": "babel-preset-react-native",
|
||||||
"version": "2.0.0-alpha.1",
|
"version": "2.0.0",
|
||||||
"description": "Babel preset for React Native applications",
|
"description": "Babel preset for React Native applications",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "https://github.com/facebook/react-native/tree/master/babel-preset",
|
"repository": "https://github.com/facebook/react-native/tree/master/babel-preset",
|
||||||
|
|
Loading…
Reference in New Issue