title: How to package only the dist folder in a monorepo
body: <p>I am using lerna and yarn workspaces in my monorepo. The package structure looks like this:</p>
  
  <pre><code>root
  `--- packages
       |--- pkg1
       |    |--- src
       |    |    `--- index.ts
       |    `--- dist
       |         `--- index.js
       `--- pkg2
            |--- src
            |    `--- index.ts
            `--- dist
                 `--- index.js
  </code></pre>
  
  <ul>
  <li><code>src</code> folder gets compiled into <code>dist</code> folder.</li>
  <li>From each package, I would like to publish only the <code>dist</code> folder so that the imports work without the need of a <code>main</code> entry in package.json pointing inside the <code>dist</code> folder. This is easy to do with lerna: <code>lerna publish --contents dist</code>.</li>
  </ul>
  
  <p>This works fine for external projects needing to use this repo, however it doesn't work within the repo itself. For example, if <code>pkg2</code>, depends on <code>pkg1</code>, it looks for pkg1's index.js file at <code>pkg1/index.js</code> while in reality the compiled version is sitting under <code>pkg1/dist/index.js</code>. How can I make this work?</p>
  
  <p>P.S. I have seen this work in repositories like <a href="https://github.com/mui-org/material-ui" rel="noreferrer">material-ui</a>, but I can't explain how it works there!</p>