babel-preset-react-native
Advanced tools
Comparing version 4.0.0 to 4.0.1
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
@@ -9,0 +7,0 @@ 'use strict'; |
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
var resolvePlugins = require('../lib/resolvePlugins'); | ||
const resolvePlugins = require('../lib/resolvePlugins'); | ||
const resolvePlugin = resolvePlugins.resolvePlugin; | ||
const defaultPlugins = resolvePlugins([ | ||
'syntax-class-properties', | ||
'syntax-trailing-function-commas', | ||
'transform-class-properties', | ||
'transform-es2015-block-scoping', | ||
'transform-es2015-computed-properties', | ||
'transform-es2015-destructuring', | ||
'transform-es2015-function-name', | ||
'transform-es2015-literals', | ||
'transform-es2015-parameters', | ||
'transform-es2015-shorthand-properties', | ||
'transform-flow-strip-types', | ||
'transform-react-jsx', | ||
'transform-regenerator', | ||
[ | ||
'transform-es2015-modules-commonjs', | ||
{strict: false, allowTopLevelThis: true}, | ||
], | ||
]); | ||
const checkES2015Constants = resolvePlugin('check-es2015-constants'); | ||
const es2015ArrowFunctions = resolvePlugin('transform-es2015-arrow-functions'); | ||
const es2015Classes = resolvePlugin('transform-es2015-classes'); | ||
const es2015ForOf = resolvePlugin(['transform-es2015-for-of', {loose: true}]); | ||
const es2015Spread = resolvePlugin('transform-es2015-spread'); | ||
const es2015TemplateLiterals = resolvePlugin( | ||
'transform-es2015-template-literals' | ||
); | ||
const asyncFunctions = resolvePlugin('syntax-async-functions'); | ||
const exponentiationOperator = resolvePlugin( | ||
'transform-exponentiation-operator' | ||
); | ||
const objectAssign = resolvePlugin('transform-object-assign'); | ||
const objectRestSpread = resolvePlugin('transform-object-rest-spread'); | ||
const reactDisplayName = resolvePlugin('transform-react-display-name'); | ||
const reactJsxSource = resolvePlugin('transform-react-jsx-source'); | ||
const symbolMember = [require('../transforms/transform-symbol-member')]; | ||
const getPreset = (src, options) => { | ||
const plugins = []; | ||
const isNull = src === null || src === undefined; | ||
@@ -21,49 +56,34 @@ const hasClass = isNull || src.indexOf('class') !== -1; | ||
plugins.push( | ||
'syntax-class-properties', | ||
'syntax-trailing-function-commas', | ||
'transform-class-properties', | ||
'transform-es2015-block-scoping', | ||
'transform-es2015-computed-properties', | ||
'transform-es2015-destructuring', | ||
'transform-es2015-function-name', | ||
'transform-es2015-literals', | ||
'transform-es2015-parameters', | ||
'transform-es2015-shorthand-properties', | ||
'transform-flow-strip-types', | ||
'transform-react-jsx', | ||
'transform-regenerator', | ||
[ | ||
'transform-es2015-modules-commonjs', | ||
{strict: false, allowTopLevelThis: true}, | ||
] | ||
); | ||
const extraPlugins = []; | ||
if (isNull || src.indexOf('async') !== -1 || src.indexOf('await') !== -1) { | ||
plugins.push('syntax-async-functions'); | ||
extraPlugins.push(asyncFunctions); | ||
} | ||
if (hasClass) { | ||
plugins.push('transform-es2015-classes'); | ||
extraPlugins.push(es2015Classes); | ||
} | ||
if (isNull || src.indexOf('=>') !== -1) { | ||
plugins.push('transform-es2015-arrow-functions'); | ||
extraPlugins.push(es2015ArrowFunctions); | ||
} | ||
if (isNull || src.indexOf('const') !== -1) { | ||
plugins.push('check-es2015-constants'); | ||
extraPlugins.push(checkES2015Constants); | ||
} | ||
if (isNull || hasClass || src.indexOf('...') !== -1) { | ||
plugins.push('transform-es2015-spread'); | ||
plugins.push('transform-object-rest-spread'); | ||
extraPlugins.push(es2015Spread); | ||
extraPlugins.push(objectRestSpread); | ||
} | ||
if (isNull || src.indexOf('`') !== -1) { | ||
plugins.push('transform-es2015-template-literals'); | ||
extraPlugins.push(es2015TemplateLiterals); | ||
} | ||
if (isNull || src.indexOf('**') !== -1) { | ||
extraPlugins.push(exponentiationOperator); | ||
} | ||
if (isNull || src.indexOf('Object.assign') !== -1) { | ||
plugins.push('transform-object-assign'); | ||
extraPlugins.push(objectAssign); | ||
} | ||
if (hasForOf) { | ||
plugins.push(['transform-es2015-for-of', {loose: true}]); | ||
extraPlugins.push(es2015ForOf); | ||
} | ||
if (hasForOf || src.indexOf('Symbol') !== -1) { | ||
plugins.push(require('../transforms/transform-symbol-member')); | ||
extraPlugins.push(symbolMember); | ||
} | ||
@@ -75,10 +95,7 @@ if ( | ||
) { | ||
plugins.push('transform-react-display-name'); | ||
extraPlugins.push(reactDisplayName); | ||
} | ||
if (isNull || src.indexOf('import(')) { | ||
plugins.push(require('../transforms/transform-dynamic-import')); | ||
} | ||
if (options && options.dev) { | ||
plugins.push('transform-react-jsx-source'); | ||
extraPlugins.push(reactJsxSource); | ||
} | ||
@@ -89,3 +106,3 @@ | ||
compact: true, | ||
plugins: resolvePlugins(plugins), | ||
plugins: defaultPlugins.concat(extraPlugins), | ||
}; | ||
@@ -92,0 +109,0 @@ }; |
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
@@ -9,0 +7,0 @@ 'use strict'; |
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
@@ -18,16 +16,22 @@ 'use strict'; | ||
function resolvePlugins(plugins) { | ||
return plugins.map(function(plugin) { | ||
// Normalise plugin to an array. | ||
if (!Array.isArray(plugin)) { | ||
plugin = [plugin]; | ||
} | ||
// Only resolve the plugin if it's a string reference. | ||
if (typeof plugin[0] === 'string') { | ||
plugin[0] = require('babel-plugin-' + plugin[0]); | ||
plugin[0] = plugin[0].__esModule ? plugin[0].default : plugin[0]; | ||
} | ||
return plugin; | ||
}); | ||
return plugins.map(resolvePlugin); | ||
} | ||
/** | ||
* Manually resolve a single Babel plugin. | ||
*/ | ||
function resolvePlugin(plugin) { | ||
// Normalise plugin to an array. | ||
if (!Array.isArray(plugin)) { | ||
plugin = [plugin]; | ||
} | ||
// Only resolve the plugin if it's a string reference. | ||
if (typeof plugin[0] === 'string') { | ||
plugin[0] = require('babel-plugin-' + plugin[0]); | ||
plugin[0] = plugin[0].__esModule ? plugin[0].default : plugin[0]; | ||
} | ||
return plugin; | ||
} | ||
module.exports = resolvePlugins; | ||
module.exports.resolvePlugin = resolvePlugin; |
{ | ||
"name": "babel-preset-react-native", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Babel preset for React Native applications", | ||
"main": "index.js", | ||
"repository": "https://github.com/facebook/react-native/tree/master/babel-preset", | ||
"repository": "https://github.com/facebook/metro/tree/master/packages/metro-react-native-babel-preset", | ||
"keywords": [ | ||
@@ -12,7 +12,7 @@ "babel", | ||
], | ||
"license": "BSD-3-Clause", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/facebook/react-native/issues" | ||
}, | ||
"homepage": "https://github.com/facebook/react-native/tree/master/babel-preset/README.md", | ||
"homepage": "https://github.com/facebook/metro/tree/master/packages/metro-react-native-babel-preset/README.md", | ||
"dependencies": { | ||
@@ -41,2 +41,3 @@ "babel-plugin-check-es2015-constants": "^6.5.0", | ||
"babel-plugin-transform-es2015-template-literals": "^6.5.0", | ||
"babel-plugin-transform-exponentiation-operator": "^6.5.0", | ||
"babel-plugin-transform-flow-strip-types": "^6.5.0", | ||
@@ -46,4 +47,4 @@ "babel-plugin-transform-object-assign": "^6.5.0", | ||
"babel-plugin-transform-react-display-name": "^6.5.0", | ||
"babel-plugin-transform-react-jsx": "^6.5.0", | ||
"babel-plugin-transform-react-jsx-source": "^6.5.0", | ||
"babel-plugin-transform-react-jsx": "^6.5.0", | ||
"babel-plugin-transform-regenerator": "^6.5.0", | ||
@@ -50,0 +51,0 @@ "babel-template": "^6.24.1", |
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
@@ -9,0 +7,0 @@ 'use strict'; |
@@ -0,1 +1,5 @@ | ||
> ## This Project Is Deprecated | ||
> `babel-preset-react-native` has been replaced by [`metro-react-native-babel-preset`](https://github.com/facebook/metro/tree/master/packages/metro-react-native-babel-preset), which now uses Babel 7.0.0. If you're using React Native v0.57 or later you should update your babel config to point to the `metro-react-native-babel-preset` preset. | ||
# babel-preset-react-native | ||
@@ -2,0 +6,0 @@ |
No website
QualityPackage does not have a website.
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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
36
0
14413
32
8
276
+ Addedbabel-plugin-transform-exponentiation-operator@^6.5.0
+ Addedbabel-helper-builder-binary-assignment-operator-visitor@6.24.1(transitive)
+ Addedbabel-helper-explode-assignable-expression@6.24.1(transitive)
+ Addedbabel-plugin-syntax-exponentiation-operator@6.13.0(transitive)
+ Addedbabel-plugin-transform-exponentiation-operator@6.24.1(transitive)