title: npm multiple module and main entry points
body: <p>I'm building a package that supports CommonJS and ES Modules. I have it working fine for a single entry point. I wrote my code as an ESM and use Babel to compile it to CJS before publishing. The pertinent bit of my <code>package.json</code> looks like this:</p>
  
  <pre><code>  "main": "cjs/",
    "module": "esm/",
    "scripts": {
      "test": "jest ./test",
      "clean": "rm -rf cjs",
      "build": "npm run clean &amp;&amp; babel esm --out-dir cjs",
      "prepare": "npm test &amp;&amp; npm run build"
    }
  </code></pre>
  
  <p>So my <code>index.js</code> is in <code>esm/index.js</code>, and <code>cjs/index.js</code> doesn't exist until the package is published. When the package is included using <code>require</code> (e.g. <code>const myPackage = require('my-package')</code>), it will pull from <code>cjs/</code>. If it's imported (e.g. <code>import myPackage from 'my-packge'</code>), it will pull from <code>esm/</code>.</p>
  
  <p>My problem is that I want to be able to import other files from the package (e.g. <code>import adapter from 'my-package/adapters/mysql'</code> or <code>const adapter = require('my-package/adapters/mysql')</code>). But if I include it in this way, the file won't be found.</p>
  
  <p>I can import it using the full path (e.g. <code>import adapter from 'my-package/esm/adapters/mysql'</code> or <code>const adapter = require('my-package/cjs/adapters/mysql')</code>). But I don't want to have to explicitly specify the module type in the path. It seems like node already knows how to tell the difference between CJS and an ES module (it knows to require from <code>main</code> and import from <code>module</code>), so I'm hoping it's possible to do the same with multiple files.</p>
  
  <p>Is there any way to include a package, as I've described above, without having to explicitly specify the path to either <code>esm/</code> or <code>cjs/</code>?</p>