Skip to content

Commit

Permalink
Adds process.env.NODE_ENV polyfill
Browse files Browse the repository at this point in the history
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: reduxjs/react-redux#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 #2279
Github Author: Dave Sibiski <dsibiski@gmail.com>
  • Loading branch information
dsibiski committed Aug 11, 2015
1 parent a303a42 commit e163df3
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ function setupProfile() {
require('BridgeProfiling').swizzleReactPerf();
}

function setUpProcessEnv() {
GLOBAL.process = {env: {NODE_ENV: __DEV__ ? 'development' : 'production'}};
}

setUpRedBoxErrorHandler();
setUpTimers();
setUpAlert();
Expand All @@ -138,3 +142,4 @@ setUpRedBoxConsoleErrorHandler();
setUpGeolocation();
setUpWebSockets();
setupProfile();
setUpProcessEnv();

0 comments on commit e163df3

Please sign in to comment.