https://github.com/4Catalyzer/babel-plugin-dev-expression
A mirror of Facebook's dev-expression Babel plugin
https://github.com/4Catalyzer/babel-plugin-dev-expression
Last synced: 23 days ago
JSON representation
A mirror of Facebook's dev-expression Babel plugin
- Host: GitHub
- URL: https://github.com/4Catalyzer/babel-plugin-dev-expression
- Owner: 4Catalyzer
- License: mit
- Created: 2015-11-02T19:17:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-03T02:17:12.000Z (about 1 month ago)
- Last Synced: 2025-03-17T05:04:35.698Z (30 days ago)
- Language: JavaScript
- Size: 319 KB
- Stars: 186
- Watchers: 6
- Forks: 6
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - babel-plugin-dev-expression - A mirror of Facebook's dev-expression Babel plugin (JavaScript)
- awesome-list - babel-plugin-dev-expression - expression Babel plugin | 4Catalyzer | 168 | (JavaScript)
README
# babel-plugin-dev-expression [](https://badge.fury.io/js/babel-plugin-dev-expression)
A mirror of Facebook's dev-expression Babel plugin.
This plugin reduces or eliminates development checks from production code.
## `__DEV__`
Replaces
```js
__DEV__
```with
```js
process.env.NODE_ENV !== 'production'
```**Note:** The `dev-expression` transform does not run when `NODE_ENV` is `test`. As such, if you use `__DEV__`, you will need to define it as a global constant in your test environment.
## `invariant`
Replaces
```js
invariant(condition, argument, argument);
```with
```js
if (!condition) {
if ("production" !== process.env.NODE_ENV) {
invariant(false, argument, argument);
} else {
invariant(false);
}
}
```Recommended for use with https://github.com/zertosh/invariant or smaller https://github.com/alexreardon/tiny-invariant.
## `warning`
Replaces
```js
warning(condition, argument, argument);
```with
```js
if ("production" !== process.env.NODE_ENV) {
warning(condition, argument, argument);
}
```Recommended for use with https://github.com/r3dm/warning or smaller https://github.com/alexreardon/tiny-warning.