Closed alex-mcleod closed 8 years ago
The main point of this lib is to cache the value of process.env.NODE_ENV
. See https://github.com/zertosh/invariant#node. Is the problem with the name __DEV__
? How can I repro?
I want to start using this package with react-native too. I did not test it in production mode yet. But I know, that React-Native has a global __DEV__
variable by default and no process.env.NODE_EN
I think.
The react-native
package already has an invariant
haste module. Isn't it reachable from user code?
@zertosh it is the naming of the __DEV__
variable which is causing the issue, so perhaps the best solution in retrospect would be to just change the name of that variable to __DEVELOPMENT__
. React native does have it's own invariant
module, however this version of invariant is a dependency for the react-intl
package which I wished to use with react-native
.
How about this then?
var NODE_ENV = process.env.NODE_ENV;
var invariant = function(condition, format, a, b, c, d, e, f) {
if (NODE_ENV !== 'production') {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
If that works, then please squash the commits and don't include a version bump.
That works. Have updated and squashed the commits.
thanks! published as invariant@2.2.1
Setting the DEV var causes release builds to fail on react native. I discovered this while using the react-intl library, which has a dependency on this library. So, I've removed usage of DEV to make this library compatible with react-native.