title: Supporting node and es-module style imports for typescript package
body: <p>I have a project that I am converting from JS (transpiled via babel) to Typescript. The module consists of a single function and uses an <code>module.exports = myFunction</code> to set it as the default.</p>
  
  <p>The issue that I've run into is that I'd like to preserve <code>require</code> format for <code>node</code> users:</p>
  
  <pre><code>const myModule = require('my-module')
  </code></pre>
  
  <p>still allow es module aware users (typescript/babel) to <code>import</code>:</p>
  
  <pre><code>import myModule from 'my-module'
  </code></pre>
  
  <p>I've seen the <a href="https://github.com/alexjoverm/typescript-library-starter" rel="nofollow noreferrer"><code>typescript-library-starter</code></a> which has a separate build process using <code>rollup</code> to emit UMDified version of the module that translates the <code>module.exports.default = myModule</code> to a node style <code>module.exports = myModule</code> but I'd prefer not to have to include an entirely separate build system for server side code (this is server only, so there's no great need for the tree-shaking/compression that rollup provides).</p>
  
  <p>Currently, I can do something like the following</p>
  
  <pre><code>export = myFunction
  </code></pre>
  
  <p>which will support the <code>const myModule = require('my-module')</code> use case, but means that TS/es module users will need to do something like:</p>
  
  <pre><code>import * as myModule from 'my-module'
  </code></pre>
  
  <p>or drop back to a simple <code>const myModule = require('my-module')</code> (which removes the benefits of typescript). </p>
  
  <p>Is there a pattern to distribute my module that works for both node style requires and es-module style imports?</p>