Skip to content

4Catalyzer/babel-plugin-dev-expression

Repository files navigation

babel-plugin-dev-expression npm version

A mirror of Facebook's dev-expression Babel plugin.

This plugin reduces or eliminates development checks from production code.

__DEV__

Replaces

__DEV__

with

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

invariant(condition, argument, argument);

with

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

warning(condition, argument, argument);

with

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.

About

A mirror of Facebook's dev-expression Babel plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published