title: package dependencies with rollup and rollup bundle strategy
body: <p>I'm working on a NPM package that use rollup to bundle and publish to npm. I want to understand if a dependency should be bundled by rollup or not, what is the best practice.
  Here is my step-by-step analysis:</p>
  <ol>
  <li><p>Every dependencies that is used in 'src' should be added to either 'deps' or 'peerDeps'</p>
  </li>
  <li><p>If you choose to put it only in 'peerDeps', not 'deps', considering the local build purpose, it is better to add to 'devDeps'. Otherwise, you may have to use 3rd party tools to install dependencies in 'peerDeps', or maybe upgrade to npm@7 (I don't use npm@7 yet)
  I guess this part has dispution, but this topic is not really about 'peerDeps' so let's continue.</p>
  </li>
  <li><p>rollup will bundle every dependencies that is used in 'src', if it is not excluded in 'external' configuration. it by default doesn't care if the dependency is mentioned in 'deps' or 'peerDeps' or 'devDeps'.</p>
  </li>
  </ol>
  <p>But that doesn't seem an expected way. For any dependencies that is in 'deps', projects that use this package, will install this dependency and then webpack can handle and process. rollup doesn't need to put it into the bundle file.
  If so, means we need to let rollup to treat any dependencies that comes from 3rd party are external? maybe using this strategy:</p>
  <pre><code>// https://github.com/remix-run/react-router/blob/v5.2.0/packages/react-router/rollup.config.js
  function isBareModuleId(id) {
    return (
      !id.startsWith(&quot;.&quot;) &amp;&amp; !id.includes(path.join(process.cwd(), &quot;modules&quot;))
    );
  }
  </code></pre>
  <p>or to use <a href="https://www.npmjs.com/package/rollup-plugin-peer-deps-external" rel="nofollow noreferrer">rollup-plugin-peer-deps-external</a>:</p>
  <pre><code>peerDepsExternal({
    includeDependencies: true,  // FIXME: 'deprecated', no idea why?
  }),
  </code></pre>
  <p>I want to finger out the best practice here, hope someone can correct me if any step of thought is incorrect. Any advices is welcomed.</p>
  <p>Thanks.</p>