forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract Babel configuration to babel-preset-react-app (facebook#701)
- Loading branch information
Showing
6 changed files
with
99 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# babel-preset-react-app | ||
|
||
This package includes the Babel preset used by [Create React App](https://github.com/facebookincubator/create-react-app). | ||
|
||
## Usage in Create React App Projects | ||
|
||
The easiest way to use this configuration is with [Create React App](https://github.com/facebookincubator/create-react-app), which includes it by default. **You don’t need to install it separately in Create React App projects.** | ||
|
||
## Usage Outside of Create React App | ||
|
||
If you want to use this ESLint configuration in a project not built with Create React App, you can install it with following steps. | ||
|
||
First, [install Babel](https://babeljs.io/docs/setup/). | ||
|
||
Then create a file named `.babelrc` with following contents in the root folder of your project: | ||
|
||
```js | ||
{ | ||
"presets": ["react-app"] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* 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. | ||
*/ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
|
||
module.exports = { | ||
presets: [ | ||
// Latest stable ECMAScript features | ||
require.resolve('babel-preset-latest'), | ||
// JSX, Flow | ||
require.resolve('babel-preset-react') | ||
], | ||
plugins: [ | ||
// class { handleClick = () => { } } | ||
require.resolve('babel-plugin-transform-class-properties'), | ||
// { ...todo, completed: true } | ||
require.resolve('babel-plugin-transform-object-rest-spread'), | ||
// function* () { yield 42; yield 43; } | ||
[require.resolve('babel-plugin-transform-regenerator'), { | ||
// Async functions are converted to generators by babel-preset-latest | ||
async: false | ||
}], | ||
// Polyfills the runtime needed for async/await and generators | ||
[require.resolve('babel-plugin-transform-runtime'), { | ||
helpers: false, | ||
polyfill: false, | ||
regenerator: true, | ||
// Resolve the Babel runtime relative to the config. | ||
moduleName: path.dirname(require.resolve('babel-runtime/package')) | ||
}] | ||
], | ||
env: { | ||
production: { | ||
plugins: [ | ||
// Optimization: hoist JSX that never changes out of render() | ||
// Disabled because of issues: | ||
// * https://github.com/facebookincubator/create-react-app/issues/525 | ||
// * https://phabricator.babeljs.io/search/query/pCNlnC2xzwzx/ | ||
// * https://github.com/babel/babel/issues/4516 | ||
// TODO: Enable again when these issues are resolved. | ||
// require.resolve('babel-plugin-transform-react-constant-elements') | ||
] | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "babel-preset-react-app", | ||
"version": "0.0.1", | ||
"description": "Babel preset used by Create React App", | ||
"repository": "facebookincubator/create-react-app", | ||
"license": "BSD-3-Clause", | ||
"bugs": { | ||
"url": "https://github.com/facebookincubator/create-react-app/issues" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"babel-plugin-transform-class-properties": "6.11.5", | ||
"babel-plugin-transform-object-rest-spread": "6.8.0", | ||
"babel-plugin-transform-react-constant-elements": "6.9.1", | ||
"babel-plugin-transform-regenerator": "6.14.0", | ||
"babel-plugin-transform-runtime": "6.15.0", | ||
"babel-preset-latest": "6.14.0", | ||
"babel-preset-react": "6.11.1", | ||
"babel-runtime": "6.11.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters