Skip to content

Commit

Permalink
document react development mode & add a way to override it
Browse files Browse the repository at this point in the history
  • Loading branch information
vikr01 committed Oct 3, 2018
1 parent 7c713f0 commit 93ef4bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ You may override our default debug option by providing your own `debug` key.
}
```

## React Development Mode

When the `envName` for `babel` is `development`, [the `develoment` mode will be set for `@babel/preset-react`](https://babeljs.io/docs/en/babel-preset-react#development).

To override this, set the `devEnv` option to a value that [`api.env`](https://babeljs.io/docs/en/next/config-files#apienv) accepts.

## React PropTypes removal

This preset can be configured to remove propTypes using [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) with the following default options:
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module.exports = declare((api, options) => {

const debug = (options && typeof options.debug === 'boolean') ? !!options.debug : false;

const { devEnv = 'development' } = options || {};

api.assertVersion(7);

return {
Expand All @@ -36,7 +38,7 @@ module.exports = declare((api, options) => {
modules: options.modules,
targets: transpileTargets,
}],
[require('@babel/preset-react'), { development: api.env('development') }],
[require('@babel/preset-react'), { development: api.env(devEnv) }],
],
plugins: [
options && !!options.removePropTypes ? ['babel-plugin-transform-react-remove-prop-types', assign({
Expand Down

0 comments on commit 93ef4bb

Please sign in to comment.