title: Write Requirejs modules that work without requirejs
body: <p>I would like to create my modules in a way, that they can be used with and without requirejs (without require js they should just work normally, so I have to make sure they load correctly, like putting script tags in the right order).</p>
  
  <p>So jQuery does it kindof like this:</p>
  
  <pre><code>// export module
  if ( typeof define === "function" &amp;&amp; define.amd ) {     
      define(["dep"], function(dep){
          dep.fn.test = test;
          return dep;
      });
  }
  else{ 
      dep.fn.test = test;
  }
  </code></pre>
  
  <p>The actual module is defined as like so</p>
  
  <pre><code>var dep = function(...){...}
  </code></pre>
  
  <p>This definition and the export part is within an IIFE to keep everything in out of the global scope.</p>
  
  <p>Generally it works well with one exception, the dependency is not available.
  This problem can be solved by defining the function within the define part, but this would mean defining it twice, in the define part and below in the else part.</p>
  
  <p>How can I get this to work but only define the module once?</p>
  
  <p><strong>I have "plugin-like" extensions to a core dep which should all be in separate files so the main dep must be passed as a depenency</strong></p>
  
  <p>This works fine btw. but it would mean I write the code for test twice.</p>
  
  <pre><code>(function(){
      // export module
      if ( typeof define === "function" &amp;&amp; define.amd ) {     
          define(["dep"], function(dep){
              dep.fn.test = function(){...ssomething using dep...};
              return dep;
          });
      }
      else{ 
          dep.fn.test = unction(){...ssomething using dep...};
      }
  
  })
  </code></pre>
  
  <p>Okay, I try another example</p>
  
  <p><strong>animate/animate.js</strong> (this is my main file)</p>
  
  <pre><code>define(function(){
    ...
    return animate;
  });
  </code></pre>
  
  <p><strong>animate/modules/easing.js</strong> (this is a module file)
      (function(){
      var ease = function(){
        // using animate main function from animate.js
        // animate is not available here 
        ...
      };</p>
  
  <pre><code>if ( typeof define === "function" &amp;&amp; define.amd ) {
      define(["animate/animate"], function(animate){
        // animate is available here
        ...
       animate.fn.ease = ease;
       return animate;
      });
  }
  else
  {
      // if no requirejs, animate is global
      animate.fn.ease = ease;
  }
  });
  </code></pre>