title: Is there a way to bootstrap only the changed packages and their dependencies?
body: <p>I am investigating the features of Lerna to try and speed up our bootstrap process which currently takes quite a long time.</p>
  <blockquote>
  <p>When referring to <code>bootstrap</code> here I am referring to the process of running <code>npm install</code> with hoisting and linking local packages together</p>
  </blockquote>
  <p>One of the things I am trying to do is only build the packages that I have changed in a branch. Take this example project</p>
  <pre><code>Package CLI
  Package Header
  Package Footer
  Package WebApp : Depends on Header &amp; Footer
  </code></pre>
  <p>With this scenario what I want to do in CI is:</p>
  <ul>
  <li>If I only change the <code>CLI</code> project then only the <code>CLI</code> project should go through <code>bootstrap -&gt; build -&gt; test</code></li>
  <li>Only changing <code>Header</code> should do the process for <code>Header</code>, <code>Footer</code> and <code>WebApp</code> because we want to ensure the dependency hasn't broken anything</li>
  <li>Only changing <code>Footer</code> should do the process for <code>Header</code>, <code>Footer</code> and <code>WebApp</code> because we want to ensure the dependency hasn't broken anything</li>
  <li>Only changing <code>WebApp</code> should do the process for <code>Header</code>, <code>Footer</code> and <code>WebApp</code> because we need to use the dependencies to check <code>WebApp</code></li>
  </ul>
  <p>The first thing I have looked at is using the <a href="https://lerna.js.org/docs/features/run-tasks#run-tasks-affected-by-a-pr" rel="nofollow noreferrer">jobs affected by a PR</a>. This works for executing a script defined in the package.json, but only for the package itself and not its dependencies. In my example if I change <code>CLI</code> then the job only runs in the <code>CLI</code> package as I want, but if I change <code>WebApp</code> then it only runs in <code>WebApp</code> and it doesn't run on the dependencies <code>Header</code> and <code>Footer</code>. This is only for running an npm script rather than <code>bootstrap</code> anyway so I am not even sure this is the correct thing to be looking into.</p>
  <p>Secondly I was looking into using <a href="https://lerna.js.org/docs/getting-started#target-dependencies-aka-task-pipelines" rel="nofollow noreferrer">task pipelines</a>. So for example in the <code>package.json</code> of the <code>WebApp</code> I have</p>
  <pre><code>&quot;dependencies&quot;: {
      &quot;header&quot;: &quot;*&quot;,
      &quot;footer&quot;: &quot;*&quot;
  }
  </code></pre>
  <p>And then in the <code>Lerna.json</code> I have</p>
  <pre><code>{
    &quot;version&quot;: &quot;3.0.0&quot;,
    ...
      &quot;targetDefaults&quot;: {
          &quot;build&quot;: {
              &quot;dependsOn&quot;: [
                  &quot;^build&quot;
              ]
          },
          &quot;test&quot;: {
              &quot;dependsOn&quot;: [
                  &quot;^build&quot;
              ]
          }
      },
    &quot;useNx&quot;: true
  }
  </code></pre>
  <p>As far as I can tell though when I run test on <code>WebApp</code> using <code>$ npx lerna run test --scope=webapp</code> I can't see any output relating to it doing anything with it's dependencies. Additionally, I still think this doesn't account for the <code>bootstrap</code> process needed before the <code>build</code> step.</p>