-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typical use case isn't well documented #21
Comments
I am trying to use this in a react-native project. I've added babel-plugin-dev-expression and in .babelrc -> plugins added babel-plugin-dev-expression. But get the error below when running the app.
Anyone know why? react-native: v0.42.3 |
Came here looking for the same thing (what's the recommended approach for removing the messages in production builds). Only thing that immediately comes to mind: function broadcast( message ) {
invariant( typeof message === 'string', process.env.NODE_ENV !== 'production' ? "Message must be defined." : undefined );
// Do some stuff here...
} Is there not a better way? |
Found this babel transform: https://github.com/bloodyowl/strip-invariant Suspect Facebook is doing something similar (stripping message arguments in build), but don't have time to investigate at the moment. |
https://github.com/husscode/babel-plugin-strip-invariant 🚀 |
It'd be useful if the README referred to babel-plugin-dev-expression, or similar, as the way to actually strip out the messages passed to
invariant
whenNODE_ENV=production
.As it is, the source simply states:
but doesn't explain how that actually happens.
The README doesn't clear it up either; it says how to install
invariant
, but that alone won't result in the intended benefit of this module, that is, fewer bytes in production builds.Unless I'm missing something?
The text was updated successfully, but these errors were encountered: