title: How can I have webpack skip a module if it doesn't exist
body: <p>I'm trying to use WebPack to include "showdown". The problem is that showdown will require("fs") and check the return value. This makes WebPack throw an error.</p>
  
  <p>It seems like it should be possible to configure Webpack to generate a shim so that call to require("fs") will return false.</p>
  
  <p>Maybe one of these techniques might work: <a href="http://webpack.github.io/docs/shimming-modules.html" rel="nofollow">http://webpack.github.io/docs/shimming-modules.html</a></p>
  
  <p>Here's the Showdown.js code. If I comment out this code inside the node modules directory, the problem is solved. However, there should be a better way.</p>
  
  <pre><code>//
  // Automatic Extension Loading (node only):
  //
  
  if (typeof module !== 'undefind' &amp;&amp; typeof exports !== 'undefined' &amp;&amp; typeof require !== 'undefind') {
      var fs = require('fs');
  
      if (fs) {
          // Search extensions folder
          var extensions = fs.readdirSync((__dirname || '.')+'/extensions').filter(function(file){
              return ~file.indexOf('.js');
          }).map(function(file){
              return file.replace(/\.js$/, '');
          });
          // Load extensions into Showdown namespace
          Showdown.forEach(extensions, function(ext){
              var name = stdExtName(ext);
              Showdown.extensions[name] = require('./extensions/' + ext);
          });
      }
  }
  </code></pre>