Skip to content

Commit

Permalink
Enable ?. plugins in RN
Browse files Browse the repository at this point in the history
Summary: Enable the optional chaining operator plugins for React Native.

Reviewed By: rafeca

Differential Revision: D7828244

fbshipit-source-id: 659a8a82ff6d656a5cb2f33377d85b668b93a9ea
  • Loading branch information
Peter van der Zee authored and facebook-github-bot committed May 2, 2018
1 parent 9927d20 commit aa6f394
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions babel-preset/configs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const exponentiationOperator = [
];
const objectAssign = [require('@babel/plugin-transform-object-assign')];
const objectRestSpread = [require('@babel/plugin-proposal-object-rest-spread')];
const optionalChaining = [require('@babel/plugin-proposal-optional-chaining')];
const reactDisplayName = [
require('@babel/plugin-transform-react-display-name'),
];
Expand Down Expand Up @@ -98,6 +99,9 @@ const getPreset = (src, options) => {
) {
extraPlugins.push(reactDisplayName);
}
if (isNull || src.indexOf('?.') !== -1) {
extraPlugins.push(optionalChaining);
}

if (options && options.dev) {
extraPlugins.push(reactJsxSource);
Expand Down
1 change: 1 addition & 0 deletions babel-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@babel/plugin-proposal-class-properties": "7.0.0-beta.40",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.40",
"@babel/plugin-proposal-optional-chaining": "7.0.0-beta.40",
"@babel/plugin-transform-arrow-functions": "7.0.0-beta.40",
"@babel/plugin-transform-block-scoping": "7.0.0-beta.40",
"@babel/plugin-transform-classes": "7.0.0-beta.40",
Expand Down

0 comments on commit aa6f394

Please sign in to comment.