Skip to content

Commit fae1b21

Browse files
existentialismrandycoulman
authored andcommitted
Enable useBuiltIns option on object-rest-spread (facebook#902)
* Enable useBuiltIns option on object-rest-spread * note polyfill requirement * Enable useBuiltIns with transform-react-jsx * Add direct ref to transform-react-jsx
1 parent efef1ba commit fae1b21

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

packages/babel-preset-react-app/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ Then create a file named `.babelrc` with following contents in the root folder o
2323
"presets": ["react-app"]
2424
}
2525
```
26+
27+
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.

packages/babel-preset-react-app/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ var path = require('path');
1313
const plugins = [
1414
// class { handleClick = () => { } }
1515
require.resolve('babel-plugin-transform-class-properties'),
16+
// The following two plugins use Object.assign directly, instead of Babel's
17+
// extends helper. Note that this assumes `Object.assign` is available.
1618
// { ...todo, completed: true }
17-
require.resolve('babel-plugin-transform-object-rest-spread'),
19+
[require.resolve('babel-plugin-transform-object-rest-spread'), {
20+
useBuiltIns: true
21+
}],
22+
// Transforms JSX
23+
[require.resolve('babel-plugin-transform-react-jsx'), {
24+
useBuiltIns: true
25+
}],
1826
// function* () { yield 42; yield 43; }
1927
[require.resolve('babel-plugin-transform-regenerator'), {
2028
// Async functions are converted to generators by babel-preset-latest

packages/babel-preset-react-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"babel-plugin-transform-class-properties": "6.16.0",
1515
"babel-plugin-transform-object-rest-spread": "6.19.0",
1616
"babel-plugin-transform-react-constant-elements": "6.9.1",
17+
"babel-plugin-transform-react-jsx": "6.8.0",
1718
"babel-plugin-transform-react-jsx-self": "6.11.0",
1819
"babel-plugin-transform-react-jsx-source": "6.9.0",
1920
"babel-plugin-transform-regenerator": "6.16.1",

0 commit comments

Comments
 (0)