title: RequireJS optimization when using variables in require() calls
body: <p>I am using <a href="http://requirejs.org/" rel="nofollow">RequireJS</a> and the <a href="https://github.com/jrburke/r.js/" rel="nofollow">r.js</a> optimizer to build a production-ready app. I noticed that when passing a variable to a <code>require()</code> call, everything works as expected.</p>
  
  <pre><code>var someDependencies = ["dependency-1", "dependency-2", "dependency-3"];
  require(someDependencies);
  </code></pre>
  
  <p>However, when running the optimizer the dependencies aren't read from the variable, and therefore aren't included in the concatenated app script. As I understand it, this is because <code>r.js</code> looks for string literals inside of <code>require()</code> calls. It does not process JavaScript, so a variable means nothing to it. This is even stated in the <a href="http://requirejs.org/docs/optimization.html" rel="nofollow">documentation for r.js</a>.</p>
  
  <blockquote>
    <p>The optimizer will only combine modules that are specified in arrays
    of string literals that are passed to top-level require and define
    calls, or the require('name') string literal calls in a simplified
    CommonJS wrapping. So, it will not find modules that are loaded via a
    variable name.</p>
  </blockquote>
  
  <p>My question is: Is there any way to overcome this so that I can pass variables into <code>require()</code> calls but still include them in the r.js build?</p>