title: Using moment.js with lang file and require.js
body: <p>I'm currently trying to use the moment.js library with require.js and I'm still having trouble understanding the correct setup of such a project. Here is what I do in my main.js file:</p>
  
  <pre><code>requirejs.config({
      baseUrl: 'app',
  
          paths: {
              // ... more parameters (all Backbone related)
              'moment': 'lib/moment',
              'moment_de': 'lib/lang/de',
          },
  
      shim: {
          'moment' : {
              deps: [],
          },
  
          'moment_de': {
              deps: ['moment'],
          },
  
          // ... more parameters (all Backbone related)
      }
  });
  </code></pre>
  
  <p>I'm using a separate module for configuration purposes. The module looks like this:</p>
  
  <pre><code>define(['moment', 'moment_de'], function(moment, de) {
  
      moment.lang('de');
  
      var configuration = {}
      // ...    
      return configuration;
  });
  </code></pre>
  
  <p>As you can see, I'm trying to change the global language of the moment object in this file, but I'm running into the following error messages:</p>
  
  <pre><code>Uncaught Error: Module name "../moment" has not been loaded yet for context: _. Use require([])
  </code></pre>
  
  <p>And later on:</p>
  
  <pre><code>Uncaught TypeError: Cannot call method 'preparse' of undefined 
  </code></pre>
  
  <p>The first error message is the language module which is being loaded although it should be loaded AFTER the moment module (if I'm doing it right). The second one is from the moment module that is trying to switch to the language module which hasn't been loaded.</p>
  
  <p>Could someone please shine some light on this issue. Thanks in advance.</p>
  
  <p><strong>EDIT</strong>: I fixed the problem using the minified language versions (e.g. <a href="https://github.com/timrwood/moment/blob/develop/min/lang/de.js">this one</a>). Apparently the minified versions are using the AMD format, which allow for an easier inclusion in require.js projects). </p>
  
  <p>I still don't quite understand why it is not possible to include the languages using the shim config, though. Maybe someone could try to explain that.</p>