From bc81bf46c284409410b4d7f040e7d6994f3b6a65 Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Mon, 21 Nov 2016 16:08:58 -0600 Subject: [PATCH] Enable useBuiltIns option on object-rest-spread (#902) * Enable useBuiltIns option on object-rest-spread * note polyfill requirement * Enable useBuiltIns with transform-react-jsx * Add direct ref to transform-react-jsx --- packages/babel-preset-react-app/README.md | 2 ++ packages/babel-preset-react-app/index.js | 10 +++++++++- packages/babel-preset-react-app/package.json | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/README.md b/packages/babel-preset-react-app/README.md index c7548b84531..5221c41af59 100644 --- a/packages/babel-preset-react-app/README.md +++ b/packages/babel-preset-react-app/README.md @@ -23,3 +23,5 @@ Then create a file named `.babelrc` with following contents in the root folder o "presets": ["react-app"] } ``` + +This preset uses the `useBuiltIns` option with [transform-object-rest-spread](http://babeljs.io/docs/plugins/transform-object-rest-spread/) and [transform-react-jsx](http://babeljs.io/docs/plugins/transform-react-jsx/), which assumes that `Object.assign` is available or polyfilled. diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index a2639c6d4cf..1f7ec0f8e0e 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -13,8 +13,16 @@ var path = require('path'); const plugins = [ // class { handleClick = () => { } } require.resolve('babel-plugin-transform-class-properties'), + // The following two plugins use Object.assign directly, instead of Babel's + // extends helper. Note that this assumes `Object.assign` is available. // { ...todo, completed: true } - require.resolve('babel-plugin-transform-object-rest-spread'), + [require.resolve('babel-plugin-transform-object-rest-spread'), { + useBuiltIns: true + }], + // Transforms JSX + [require.resolve('babel-plugin-transform-react-jsx'), { + useBuiltIns: true + }], // function* () { yield 42; yield 43; } [require.resolve('babel-plugin-transform-regenerator'), { // Async functions are converted to generators by babel-preset-latest diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 13f00ed227d..08a210674ee 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -14,6 +14,7 @@ "babel-plugin-transform-class-properties": "6.16.0", "babel-plugin-transform-object-rest-spread": "6.19.0", "babel-plugin-transform-react-constant-elements": "6.9.1", + "babel-plugin-transform-react-jsx": "6.8.0", "babel-plugin-transform-react-jsx-self": "6.11.0", "babel-plugin-transform-react-jsx-source": "6.9.0", "babel-plugin-transform-regenerator": "6.16.1",