babel-preset-react-native
Advanced tools
Comparing version
@@ -8,2 +8,4 @@ /** | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @format | ||
*/ | ||
@@ -14,48 +16,93 @@ 'use strict'; | ||
var base = { | ||
comments: false, | ||
compact: true, | ||
plugins: resolvePlugins([ | ||
'syntax-async-functions', | ||
const getPreset = (src, options) => { | ||
const plugins = []; | ||
const isNull = src === null || src === undefined; | ||
const hasClass = isNull || src.indexOf('class') !== -1; | ||
const hasForOf = | ||
isNull || (src.indexOf('for') !== -1 && src.indexOf('of') !== -1); | ||
plugins.push( | ||
'syntax-class-properties', | ||
'syntax-trailing-function-commas', | ||
'transform-class-properties', | ||
'transform-es2015-function-name', | ||
'transform-es2015-arrow-functions', | ||
'transform-es2015-block-scoping', | ||
'transform-es2015-classes', | ||
'transform-es2015-computed-properties', | ||
'check-es2015-constants', | ||
'transform-es2015-destructuring', | ||
['transform-es2015-modules-commonjs', { strict: false, allowTopLevelThis: true }], | ||
'transform-es2015-function-name', | ||
'transform-es2015-literals', | ||
'transform-es2015-parameters', | ||
'transform-es2015-shorthand-properties', | ||
'transform-es2015-spread', | ||
'transform-es2015-template-literals', | ||
'transform-es2015-literals', | ||
'transform-flow-strip-types', | ||
'transform-object-assign', | ||
'transform-object-rest-spread', | ||
'transform-react-display-name', | ||
'transform-react-jsx', | ||
'transform-regenerator', | ||
['transform-es2015-for-of', { loose: true }], | ||
require('../transforms/transform-regenerator-runtime-insertion'), | ||
require('../transforms/transform-symbol-member'), | ||
]), | ||
[ | ||
'transform-es2015-modules-commonjs', | ||
{strict: false, allowTopLevelThis: true}, | ||
], | ||
); | ||
if (isNull || src.indexOf('async') !== -1 || src.indexOf('await') !== -1) { | ||
plugins.push('syntax-async-functions'); | ||
} | ||
if (hasClass) { | ||
plugins.push('transform-es2015-classes'); | ||
} | ||
if (isNull || src.indexOf('=>') !== -1) { | ||
plugins.push('transform-es2015-arrow-functions'); | ||
} | ||
if (isNull || src.indexOf('const') !== -1) { | ||
plugins.push('check-es2015-constants'); | ||
} | ||
if (isNull || hasClass || src.indexOf('...') !== -1) { | ||
plugins.push('transform-es2015-spread'); | ||
plugins.push('transform-object-rest-spread'); | ||
} | ||
if (isNull || src.indexOf('`') !== -1) { | ||
plugins.push('transform-es2015-template-literals'); | ||
} | ||
if (isNull || src.indexOf('Object.assign') !== -1) { | ||
plugins.push('transform-object-assign'); | ||
} | ||
if (hasForOf) { | ||
plugins.push(['transform-es2015-for-of', {loose: true}]); | ||
} | ||
if (hasForOf || src.indexOf('Symbol') !== -1) { | ||
plugins.push(require('../transforms/transform-symbol-member')); | ||
} | ||
if ( | ||
isNull || | ||
src.indexOf('React.createClass') !== -1 || | ||
src.indexOf('createReactClass') !== -1 | ||
) { | ||
plugins.push('transform-react-display-name'); | ||
} | ||
if (isNull || src.indexOf('import(')) { | ||
plugins.push(require('../transforms/transform-dynamic-import')); | ||
} | ||
if (options && options.dev) { | ||
plugins.push('transform-react-jsx-source'); | ||
} | ||
return { | ||
comments: false, | ||
compact: true, | ||
plugins: resolvePlugins(plugins), | ||
}; | ||
}; | ||
var devTools = Object.assign({}, base); | ||
devTools.plugins = devTools.plugins.concat( | ||
resolvePlugins(['transform-react-jsx-source']) | ||
); | ||
const base = getPreset(null); | ||
const devTools = getPreset(null, {dev: true}); | ||
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'; | ||
module.exports = options => { | ||
if (options.withDevTools == null) { | ||
const env = process.env.BABEL_ENV || process.env.NODE_ENV; | ||
if (!env || env === 'development') { | ||
return devTools; | ||
} | ||
} | ||
return withDevTools ? devTools : base; | ||
return base; | ||
}; | ||
module.exports.getPreset = getPreset; |
{ | ||
"name": "babel-preset-react-native", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Babel preset for React Native applications", | ||
@@ -22,2 +22,3 @@ "main": "index.js", | ||
"babel-plugin-syntax-class-properties": "^6.5.0", | ||
"babel-plugin-syntax-dynamic-import": "^6.18.0", | ||
"babel-plugin-syntax-flow": "^6.5.0", | ||
@@ -47,4 +48,5 @@ "babel-plugin-syntax-jsx": "^6.5.0", | ||
"babel-plugin-transform-regenerator": "^6.5.0", | ||
"babel-template": "^6.24.1", | ||
"react-transform-hmr": "^1.0.4" | ||
} | ||
} |
@@ -15,2 +15,3 @@ /** | ||
'babel-plugin-syntax-class-properties': require('babel-plugin-syntax-class-properties'), | ||
'babel-plugin-syntax-dynamic-import': require('babel-plugin-syntax-dynamic-import'), | ||
'babel-plugin-syntax-trailing-function-commas': require('babel-plugin-syntax-trailing-function-commas'), | ||
@@ -17,0 +18,0 @@ 'babel-plugin-transform-class-properties': require('babel-plugin-transform-class-properties'), |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17222
10.88%383
16.77%31
6.9%+ Added
+ Added