From 30b057fa9cfe7c7567884f6df8e77e97bdcaf141 Mon Sep 17 00:00:00 2001 From: Dylan Vann Date: Wed, 18 Oct 2017 16:31:42 -0700 Subject: [PATCH] Add babel-plugin-transform-exponentiation-operator to babel-preset-react-native Summary: Adds the dependency to the Babel preset's package.json and enables the plugin only when `**` exists in a source file. This is https://github.com/facebook/react-native/pull/12339 with merge conflicts resolved and putting the plugin behind a cheaper heuristic. Closes https://github.com/facebook/react-native/pull/16191 Differential Revision: D6023857 Pulled By: hramos fbshipit-source-id: 16f4a5f14780c27d2ef95fa7e8d8b611fa992aa0 --- babel-preset/configs/main.js | 3 +++ babel-preset/package.json | 3 ++- package.json | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/babel-preset/configs/main.js b/babel-preset/configs/main.js index c089b633a..7ba9288c8 100644 --- a/babel-preset/configs/main.js +++ b/babel-preset/configs/main.js @@ -57,6 +57,9 @@ const getPreset = (src, options) => { if (isNull || src.indexOf('`') !== -1) { plugins.push('transform-es2015-template-literals'); } + if (isNull || src.indexOf('**') !== -1) { + plugins.push('transform-exponentiation-operator'); + } if (isNull || src.indexOf('Object.assign') !== -1) { plugins.push('transform-object-assign'); } diff --git a/babel-preset/package.json b/babel-preset/package.json index 9d4f3495c..77e1090ed 100644 --- a/babel-preset/package.json +++ b/babel-preset/package.json @@ -37,12 +37,13 @@ "babel-plugin-transform-es2015-shorthand-properties": "^6.5.0", "babel-plugin-transform-es2015-spread": "^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", "babel-plugin-transform-object-assign": "^6.5.0", "babel-plugin-transform-object-rest-spread": "^6.5.0", "babel-plugin-transform-react-display-name": "^6.5.0", - "babel-plugin-transform-react-jsx-source": "^6.5.0", "babel-plugin-transform-react-jsx": "^6.5.0", + "babel-plugin-transform-react-jsx-source": "^6.5.0", "babel-plugin-transform-regenerator": "^6.5.0", "babel-template": "^6.24.1", "react-transform-hmr": "^1.0.4" diff --git a/package.json b/package.json index ac07ac105..8f4bd7cbb 100644 --- a/package.json +++ b/package.json @@ -142,6 +142,7 @@ "babel-plugin-syntax-trailing-function-commas": "^6.20.0", "babel-plugin-transform-async-to-generator": "6.16.0", "babel-plugin-transform-class-properties": "^6.18.0", + "babel-plugin-transform-exponentiation-operator": "^6.5.0", "babel-plugin-transform-flow-strip-types": "^6.21.0", "babel-plugin-transform-object-rest-spread": "^6.20.2", "babel-register": "^6.24.1",