Adds `process.env.NODE_ENV` polyfill

Summary:
There are many libraries that use `NODE_ENV` to check whether the code is running in
"production" mode or not. This allows those library authors to not have to add conditionals
for React Native.

One such library is Redux: https://github.com/gaearon/react-redux/pull/40

Thanks to @brentvatne for providing the solution via this tweet (via his phone in the airport 😉): https://twitter.com/notbrent/status/630440250951749632

/cc @vjeux @gaearon @zpao @amasad
Closes https://github.com/facebook/react-native/pull/2279
Github Author: Dave Sibiski <dsibiski@gmail.com>
This commit is contained in:
Dave Sibiski 2015-08-10 19:31:05 -07:00
parent a303a42e28
commit e163df3567
1 changed files with 5 additions and 0 deletions

View File

@ -129,6 +129,10 @@ function setupProfile() {
require('BridgeProfiling').swizzleReactPerf();
}
function setUpProcessEnv() {
GLOBAL.process = {env: {NODE_ENV: __DEV__ ? 'development' : 'production'}};
}
setUpRedBoxErrorHandler();
setUpTimers();
setUpAlert();
@ -138,3 +142,4 @@ setUpRedBoxConsoleErrorHandler();
setUpGeolocation();
setUpWebSockets();
setupProfile();
setUpProcessEnv();