-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ef5a8a5
Use "babel-preset-react-native"
skevy 5850f2a
rename .babelrc.json to rn-babelrc.json -- just so there's no confusion
skevy 562a05b
fixing typo where config wasn't used after updating plugin list
skevy 2542bd7
code style updates
skevy a657b46
Add babel-preset-react-native to main repo.
skevy 58b3932
Pass projectRoots to transformer, in order to check for existence of …
skevy 8f715d7
Making for..of transform loose, per discussions in facebook/react-nat…
skevy 0e05a2e
Moving internal transforms into preset.
skevy d1de361
Making transformer work when projectRoots is not set.
skevy c432941
Move HMR Babel plugin config to preset package.
skevy 30f74fe
reorganization of babel-preset files
skevy cb25018
fixing nits
skevy c76386a
Updating babel deps and use "babel-register" instead of "babel-core/r…
skevy fa77997
Fix typo in preset.
skevy d4fb3c4
Remove spread operator from worker and use Object.assign.
skevy f3264b9
Up the babel preset version.
skevy febd304
make babel-preset es5
skevy f9a93d9
bumping preset version
skevy ac526aa
adding react-transform-hmr back to deps, because it is required in In…
skevy 6dc9574
resolving presets and plugins relative to the react-native package wh…
skevy d51ea5f
remove react-transform-hmr from providesModuleNodeMoudles so it doesn…
skevy e5e3ba7
exporting plugins for use by FB internal transform
skevy a02a8d1
add react-transform babel plugin to plugin exports
skevy 658ef22
bumping babel-preset version
skevy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,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. |
This file contains hidden or 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,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'], | ||
| }] | ||
| }, | ||
| ] | ||
| ]) | ||
| }; | ||
| } |
This file contains hidden or 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,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; | ||
| } |
This file contains hidden or 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,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, | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -8,7 +8,4 @@ | |
| */ | ||
| 'use strict'; | ||
|
|
||
| exports.getAll = function(options) { | ||
| return []; | ||
| }; | ||
|
|
||
| module.exports = require('./configs/main'); | ||
File renamed without changes.
This file contains hidden or 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,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" | ||
| } | ||
| } | ||
This file contains hidden or 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,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 contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,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 |
||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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