title: How to mixin Underscore plugins in RequireJS?
body: <p>What is the right way to execute code on Underscore when it gets loaded? I am trying to execute the below code to extend the _ exported namespace automatically when modules require it:</p>
  
  <pre><code>_.mixin(_.str.exports());
  </code></pre>
  
  <p>The docs are a bit vague but I think I put it in the shim init section? I tried the below but I can't even get a breakpoint to hit in the init:</p>
  
  <pre><code>require.config({
      paths: {
          jquery: 'libs/jquery/jquery.min',
          underscore: 'libs/underscore/lodash.min',
          underscorestring: 'libs/underscore/underscore.string.min'
      },
  
      shim: {
          underscore: {
              exports: '_'
          }
          underscorestring: {
              deps: ['underscore'],
              init: function (_) {
                  //Mixin plugin to namespace
                  _.mixin(_.str.exports());
  
                  return _;
              }
          }
      }
  });
  </code></pre>
  
  <p>When I try to do this and use underscorestring, I get this error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Object function s(e){return new o(e)} has no
    method 'startsWith'</p>
  </blockquote>
  
  <p>Docs:</p>
  
  <ul>
  <li><a href="http://requirejs.org/docs/api.html#config-shim" rel="noreferrer">http://requirejs.org/docs/api.html#config-shim</a></li>
  <li><a href="http://requirejs.org/docs/api.html#config-callback" rel="noreferrer">http://requirejs.org/docs/api.html#config-callback</a></li>
  </ul>