Last active
March 6, 2018 21:15
-
-
Save RobertFischer/316eafc0a194594315fb5e4752aaa11d to your computer and use it in GitHub Desktop.
Babel Configuration File for a Nicer Development Environment
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
{ | |
"presets": [ | |
"react-native" | |
], | |
"plugins": [ | |
"transform-strict-mode", | |
[ "auto-import", | |
{ "declarations": [ | |
{ "default": "React", "path": "react" }, | |
{ "default": "_", "path": "lodash" }, | |
{ "default": "Promise", "path": "bluebird" } | |
]} | |
], | |
"react-display-name" | |
], | |
"env": { | |
"development": { | |
"plugins": [ | |
"transform-react-jsx-self", | |
"transform-react-jsx-source" | |
] | |
}, | |
"production": { | |
"presets": [ | |
"minify" | |
], | |
"plugins": [ | |
"react-constant-elements", | |
"lodash" | |
] | |
} | |
} | |
} |
Here's everything this does.
- Automatically uses Strict Mode on all your files for improved safety and performance.
- Automatically imports React as
React
, Lodash as_
, and Bluebird asPromise
. - Adds the display name property to any hand-instantiated React components.
In development (eg: when NODE_ENV
is unset or set to anything other than "production"), the following also happens:
- Adds in
__self
to the React components, which React uses to improve error messaging. - Adds in
__source
to the React components, which contains line number and file name where the component was instantiated, so you can view/log those if you're curious.
In production (eg: when NODE_ENV="production"
), the following also happens:
- Hoists constant React components to speed up diffing and rendering.
- Minimizes the code.
- Picks out the particular Lodash modules that you're building, so you don't include everything from Lodash in your resulting bundle.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation
Replace your existing
.babelrc
(https://github.com/BeeWell/development/blob/master/patient-mobile/mobile/bsncApp/.babelrc) with the file above.In the same directory as that
.babelrc
file, execute this huge statement on your command line.