title: RequireJS: Uglification Not Working
body: <p>I must be making a mistake somewhere, but it's not being written to stdout during optimization.  I'm trying to optimize a file via requirejs, but the output isn't being minified.  According to the <a href="https://github.com/requirejs/r.js/blob/master/build/example.build.js" rel="nofollow noreferrer">documentation</a>, UglifyJS should minify the code.</p>
  
  <p>At any rate, the following code is trivial, but it isolates the problem.</p>
  
  <p>src/index.js:</p>
  
  <pre><code>require(['config'], function () {
      require(['myMod'], function (myMod) {
          console.log(myMod.x());
      })
  })
  </code></pre>
  
  <p>src/myMod.js:</p>
  
  <pre><code>define(function () {
      let myMod = {
          x: 5
      };
  
      return myMod;
  })
  </code></pre>
  
  <p>src/config.js:</p>
  
  <pre><code>define(function () {
      require.config({
          baseUrl: 'src'
      });
  })
  </code></pre>
  
  <p>And here's the gulp task that is performing the optimization:</p>
  
  <pre><code>gulp.task('optimize', function (cb) {
      let config = {
          appDir: 'src',
          dir: 'dist/src',
          generateSourceMaps: true,
          preserveLicenseComments: false,
          removeCombined: true,
          baseUrl: './',
          modules: [{
              name: 'index',
              include: ['myMod']
          }]
      }
  
      let success = function (buildResponse) { console.log(buildResponse); cb() },
          error = function (err) { console.log(err); cb(err) }
  
      rjs.optimize(config, success, error)
  })
  </code></pre>
  
  <p>After running the task, dist/src/index.js has all of the other modules included in it.  However, it's not minified, and none of the variables have been renamed.  Instead, it's as if the files were just concatenated, nothing more.  Could someone tell me (1) why is it not being minified?  (2) is UglifyJS throwing an error?  If so, is there a way to see it when the gulp task is being run?</p>
  
  <p><strong>EDIT</strong> Here's a link to RequireJS docs where it talks about using the optimizer in node, which is done in the gulp task mentioned above.  It's at the bottom under "Using the optimizer as a node module".</p>
  
  <p><a href="http://requirejs.org/docs/node.html" rel="nofollow noreferrer">http://requirejs.org/docs/node.html</a></p>