A way to provide descriptive errors in development but generic errors in production.
With npm do:
npm install invariant
var invariant = ;;// No errors;// Error: Invariant Violation: This will throw an error with this message
process.env.NODE_ENV is not
production, the message is required. If omitted,
invariant will throw regardless of the truthiness of the condition. When
production, the message is optional – so they can be minified away.
The node version is optimized around the performance implications of accessing
process.env. The value of
process.env.NODE_ENV is cached, and repeatedly used instead of reading
process.env. See Server rendering is slower with npm react #812