Wrap invariant function checks in process.env.NODE_ENV
conditionals that only run in development.
// Input
invariant(value === false, 'Value must be falsy!');
// Output
if (process.env.NODE_ENV !== 'production') {
invariant(value === false, 'Value must be falsy!');
}
yarn add --dev babel-plugin-conditional-invariant
Add the plugin to your root babel.config.*
file.
module.exports = {
plugins: ['babel-plugin-conditional-invariant'],
};
- Linux, OSX, Windows
- Node 18.12+