title: 'moment is not a function' when referencing a self-made module in a React app
body: <p>I am trying to use a module I created in a simple React app using <code>react-boilerplate</code>. I am importing the module, but it is saying that <code>moment</code> within the module is undefined.</p>
  <p>Here is the error and the logged moment just to show that <code>this.props.date</code> does indeed return a moment.</p>
  <pre><code>Moment {_isAMomentObject: true, _isUTC: false, _pf: {…}, _locale: Locale, _d: 
  index.js:23 Uncaught (in promise) TypeError: moment is not a function
      at module.exports (index.js:23)
  </code></pre>
  <p>The module is on NPM and just does some simple logic based on a date using <code>moment</code>. Here is the <code>index.js</code> of that file.</p>
  <h1>daysleft/index.js</h1>
  <p>index.js</p>
  <pre><code>const moment = require('moment');
  
  moment.suppressDeprecationWarnings = true;
  module.exports = (input, opts) =&gt; {
      if (input === undefined || input === '') {
          throw new TypeError('Expected a string, got nothing');
      }
  
      if (typeof input !== 'string') {
          if (typeof input !== 'object' &amp;&amp; (input.isMoment === undefined || !input.isMoment())) {
              throw new TypeError(`Expected a string, got ${typeof input}`);
          }
      }
  
      opts = opts || {};
  
      if (opts.startDate &amp;&amp; (typeof opts.startDate !== 'string')) {
          if (typeof opts.startDate !== 'object' &amp;&amp; (opts.startDate.isMoment === undefined || !opts.startDate.isMoment())) {
              throw new TypeError(`Expected a string, got ${typeof opts.startDate}`);
          }
      }
  
      const startDate = moment(opts.startDate || moment().format('YYYY-MM-DD'));
      const endDate = moment(input);
  
      if (!endDate.isValid() || !startDate.isValid()) {
          throw new TypeError('Invalid date input');
      }
  
      return endDate.diff(startDate, 'days');
  };
  </code></pre>
  <p>I then try to use it in a react app</p>
  <h2>myApp/SomeComponent.js</h2>
  <pre><code>render() {
      return (
        &lt;Wrapper onClick={this.onClick}&gt;
          &lt;Label&gt;{this.props.name}&lt;/Label&gt;
          &lt;DateView&gt;{this.props.date.format('LL')}&lt;/DateView&gt;
          &lt;Hr /&gt;
          &lt;DaysLeftContainer&gt;
            &lt;DaysLeft&gt;
              {daysleft(moment(this.props.date))}
            &lt;/DaysLeft&gt; days left
          &lt;/DaysLeftContainer&gt;
        &lt;/Wrapper&gt;
      );
    }
  </code></pre>
  <p>Any help is greatly appreciated.</p>
  <p>Link to the daysleft module incase it's needed: <a href="https://github.com/qbolt/daysleft/" rel="nofollow noreferrer">https://github.com/qbolt/daysleft/</a></p>