Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 25.2k
Use "babel-preset-react-native"#5214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
ef5a8a55850f2a562a05b2542bd7a657b4658b39328f715d70e05a2ed1de361c43294130f74fecb25018c76386afa77997d4fb3c4f3264b9febd304f9a93d9ac526aa6dc9574d51ea5fe5e3ba7a02a8d1658ef22File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # babel-preset-react-native | ||
| Babel presets for React Native applications. React Native itself uses this Babel preset by default when transforming your app's source code. | ||
| If you wish to use a custom Babel configuration by writing a `.babelrc` file in your project's root directory, you must specify all the plugins necessary to transform your code. React Native does not apply its default Babel configuration in this case. So, to make your life easier, you can use this preset to get the default configuration and then specify more plugins that run before it. | ||
| ## Usage | ||
| As mentioned above, you only need to use this preset if you are writing a custom `.babelrc` file. | ||
| ### Installation | ||
| Install `babel-preset-react-native` in your app: | ||
| ```sh | ||
| npm i babel-preset-react-native --save-dev | ||
| ``` | ||
| ### Configuring Babel | ||
| Then, create a file called `.babelrc` in your project's root directory. The existence of this `.babelrc` file will tell React Native to use your custom Babel configuration instead of its own. Then load this preset: | ||
| ``` | ||
| { | ||
| "presets": ["react-native"] | ||
| } | ||
| ``` | ||
| You can further customize your Babel configuration by specifying plugins and other options. See [Babel's `.babelrc` documentation](https://babeljs.io/docs/usage/babelrc/) to learn more. | ||
| ## Help and Support | ||
| If you get stuck configuring Babel, please ask a question on Stack Overflow or find a consultant for help. If you discover a bug, please open up an issue. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * 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 resolvePlugins = require('../lib/resolvePlugins'); | ||
| module.exports = function(options) { | ||
| return { | ||
| plugins: resolvePlugins([ | ||
| [ | ||
| 'react-transform', | ||
| { | ||
| transforms: [{ | ||
| transform: 'react-transform-hmr/lib/index.js', | ||
| imports: ['React'], | ||
| locals: ['module'], | ||
| }] | ||
| }, | ||
| ] | ||
| ]) | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /** | ||
| * 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 resolvePlugins = require('../lib/resolvePlugins'); | ||
| module.exports = function(options) { | ||
| // For future internal pipeline usage | ||
| return null; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * 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 resolvePlugins = require('../lib/resolvePlugins'); | ||
| module.exports = { | ||
| comments: false, | ||
| compact: true, | ||
| plugins: resolvePlugins([ | ||
| 'syntax-async-functions', | ||
| 'syntax-class-properties', | ||
| 'syntax-trailing-function-commas', | ||
| 'transform-class-properties', | ||
| 'transform-es2015-arrow-functions', | ||
| 'transform-es2015-block-scoping', | ||
| 'transform-es2015-classes', | ||
| 'transform-es2015-computed-properties', | ||
| 'transform-es2015-constants', | ||
| 'transform-es2015-destructuring', | ||
| ['transform-es2015-modules-commonjs', { strict: false, allowTopLevelThis: true }], | ||
| 'transform-es2015-parameters', | ||
| 'transform-es2015-shorthand-properties', | ||
| 'transform-es2015-spread', | ||
| 'transform-es2015-template-literals', | ||
| 'transform-flow-strip-types', | ||
| 'transform-object-assign', | ||
| 'transform-object-rest-spread', | ||
| 'transform-react-display-name', | ||
| 'transform-react-jsx', | ||
| 'transform-regenerator', | ||
| ['transform-es2015-for-of', { loose: true }], | ||
| ]), | ||
| retainLines: true, | ||
| sourceMaps: false, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,7 +8,4 @@ | ||
| */ | ||
| 'use strict'; | ||
| exports.getAll = function(options) { | ||
| return []; | ||
| }; | ||
| module.exports = require('./configs/main'); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "name": "babel-preset-react-native", | ||
| "version": "1.2.3", | ||
| "description": "Babel preset for React Native applications", | ||
| "main": "index.js", | ||
| "repository": "https://github.com/facebook/react-native/tree/master/babel-preset", | ||
| "keywords": [ | ||
| "babel", | ||
| "preset", | ||
| "react-native" | ||
| ], | ||
| "license" : "BSD-3-Clause", | ||
| "bugs": { | ||
| "url": "https://github.com/facebook/react-native/issues" | ||
| }, | ||
| "homepage": "https://github.com/facebook/react-native/tree/master/babel-preset/README.md", | ||
| "dependencies": { | ||
| "babel-plugin-react-transform": "2.0.0-beta1", | ||
| "babel-plugin-syntax-async-functions": "^6.3.13", | ||
| "babel-plugin-syntax-class-properties": "^6.3.13", | ||
| "babel-plugin-syntax-flow": "^6.3.13", | ||
| "babel-plugin-syntax-jsx": "^6.3.13", | ||
| "babel-plugin-syntax-trailing-function-commas": "^6.3.13", | ||
| "babel-plugin-transform-class-properties": "^6.4.0", | ||
| "babel-plugin-transform-es2015-arrow-functions": "^6.4.0", | ||
| "babel-plugin-transform-es2015-block-scoping": "^6.4.0", | ||
| "babel-plugin-transform-es2015-classes": "^6.4.0", | ||
| "babel-plugin-transform-es2015-computed-properties": "^6.4.0", | ||
| "babel-plugin-transform-es2015-constants": "^6.1.4", | ||
| "babel-plugin-transform-es2015-destructuring": "^6.4.0", | ||
| "babel-plugin-transform-es2015-for-of": "^6.3.13", | ||
| "babel-plugin-transform-es2015-modules-commonjs": "^6.4.0", | ||
| "babel-plugin-transform-es2015-parameters": "^6.4.2", | ||
| "babel-plugin-transform-es2015-shorthand-properties": "^6.3.13", | ||
| "babel-plugin-transform-es2015-spread": "^6.4.0", | ||
| "babel-plugin-transform-es2015-template-literals": "^6.3.13", | ||
| "babel-plugin-transform-flow-strip-types": "^6.4.0", | ||
| "babel-plugin-transform-object-assign": "^6.3.13", | ||
| "babel-plugin-transform-object-rest-spread": "^6.3.13", | ||
| "babel-plugin-transform-react-display-name": "^6.4.0", | ||
| "babel-plugin-transform-react-jsx": "^6.4.0", | ||
| "babel-plugin-transform-regenerator": "^6.3.26", | ||
| "react-transform-hmr": "^1.0.1" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /** | ||
| * 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'; | ||
| module.exports = { | ||
| 'babel-plugin-react-transform': require('babel-plugin-react-transform'), | ||
| 'babel-plugin-syntax-async-functions': require('babel-plugin-syntax-async-functions'), | ||
| 'babel-plugin-syntax-class-properties': require('babel-plugin-syntax-class-properties'), | ||
| 'babel-plugin-syntax-trailing-function-commas': require('babel-plugin-syntax-trailing-function-commas'), | ||
| 'babel-plugin-transform-class-properties': require('babel-plugin-transform-class-properties'), | ||
| 'babel-plugin-transform-es2015-arrow-functions': require('babel-plugin-transform-es2015-arrow-functions'), | ||
| 'babel-plugin-transform-es2015-block-scoping': require('babel-plugin-transform-es2015-block-scoping'), | ||
| 'babel-plugin-transform-es2015-classes': require('babel-plugin-transform-es2015-classes'), | ||
| 'babel-plugin-transform-es2015-computed-properties': require('babel-plugin-transform-es2015-computed-properties'), | ||
| 'babel-plugin-transform-es2015-constants': require('babel-plugin-transform-es2015-constants'), | ||
| 'babel-plugin-transform-es2015-destructuring': require('babel-plugin-transform-es2015-destructuring'), | ||
| 'babel-plugin-transform-es2015-modules-commonjs': require('babel-plugin-transform-es2015-modules-commonjs'), | ||
| 'babel-plugin-transform-es2015-parameters': require('babel-plugin-transform-es2015-parameters'), | ||
| 'babel-plugin-transform-es2015-shorthand-properties': require('babel-plugin-transform-es2015-shorthand-properties'), | ||
| 'babel-plugin-transform-es2015-spread': require('babel-plugin-transform-es2015-spread'), | ||
| 'babel-plugin-transform-es2015-template-literals': require('babel-plugin-transform-es2015-template-literals'), | ||
| 'babel-plugin-transform-flow-strip-types': require('babel-plugin-transform-flow-strip-types'), | ||
| 'babel-plugin-transform-object-assign': require('babel-plugin-transform-object-assign'), | ||
| 'babel-plugin-transform-object-rest-spread': require('babel-plugin-transform-object-rest-spread'), | ||
| 'babel-plugin-transform-react-display-name': require('babel-plugin-transform-react-display-name'), | ||
| 'babel-plugin-transform-react-jsx': require('babel-plugin-transform-react-jsx'), | ||
| 'babel-plugin-transform-regenerator': require('babel-plugin-transform-regenerator'), | ||
| 'babel-plugin-transform-es2015-for-of': require('babel-plugin-transform-es2015-for-of'), | ||
| }; |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "presets": [ "react-native" ], | ||
| "plugins": [] | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we need to land the pr to update babel 6.3.x first, right? I think that one hasn't been merged internally. cc @davidaurelio