A Babel plugin that mirrors Facebook's dev-expression transform, reducing or eliminating development checks (invariant, warning, __DEV__) from production code. Stable version 0.2.3, low release cadence. It replaces __DEV__ with process.env.NODE_ENV !== 'production', optimizes invariant and warning calls by wrapping them with environment checks. Differentiates from manual conditional code by automating transforms and handling edge cases like stringification.
npm install babel-plugin-dev-expressionVerified import paths — ran on the pinned version, not inferred.
Shows Babel config and how __DEV__, invariant, and warning are transformed in production.
In Jest: setupFiles or jest.globals; in Mocha: global.__DEV__ = true;
Upgrade to Babel 6/7 or stay on babel-plugin-dev-expression@0.1.x.
Evaluate alternatives; the plugin is stable but unmaintained.
Ensure NODE_ENV is properly set to 'production' for builds, or disable the plugin in development.
Run npm install --save-dev babel-plugin-dev-expression or add to package.json.
Use require('babel-plugin-dev-expression') or string shorthand 'dev-expression'.Ensure babel-plugin-dev-expression is in the plugins list and NODE_ENV is set to 'production'.