title: Conditionally require modules in javascript
body: <p>I'm entering the conditional as expected (as proven by a console that is only hit in the if statement if <code>process.env.BROWSER === true</code>, but the require inside the if statement is still getting hit nomatter if <code>process.env.BROWSER === true</code> or <code>process.env.BROWSER === false</code> and this is causing and error when <code>process.env.BROWSER === false</code>. If I comment out the first require, then when <code>process.env.BROWSER === false</code> there is no error. </p>
  
  <p>I suspect that all requires are somehow called when JS is compiling, but if that's the case how can I conditionally require a module? What's exactly happening here?</p>
  
  <pre><code>if (process.env.BROWSER) {
      language['ES'].push(require('promise?global,locale-es-ES!react-intl/locale-data/es'));
  } else{
      language['ES'].push(function () {
        return Promise.resolve(require('react-intl/locale-data/es'));
      });
  }
  </code></pre>
  
  <p>using module.require like this works in react-native but throws a <code>TypeError: module.require is not a function</code> when in the Browser</p>
  
  <pre><code>if (process.env.BROWSER) {
      language['ES'].push(module.require('promise?global,locale-es-ES!react-intl/locale-data/es'));
  } else{
      language['ES'].push(function () {
        return Promise.resolve(require('react-intl/locale-data/es'));
      });
  }
  </code></pre>
  
  <p>trying to find a reference to module like this gives the <code>TypeError: Cannot read property 'require' of undefined</code></p>
  
  <pre><code>if (process.env.BROWSER) {
          language['ES'].push(require('react-intl').module.require('promise?global,locale-es-ES!react-intl/locale-data/es'));
      } else{
          language['ES'].push(function () {
            return Promise.resolve(require('react-intl/locale-data/es'));
          });
      }
  </code></pre>