title: When using Webpack to resolve directly to a sibling NPM project, how can I specify a resolve order wrt which node_modules to look at first?
body: <p>I have two npm projects, <code>project-a</code> and <code>project-b</code>. They both publish and ought to be able to be directly depended upon by any npm project in my company. <code>project-a</code> depends on <code>project-b</code>. They both live as siblings in the same Git repo.</p>
  
  <p>I want to directly import certain components from <code>project-b</code> into <code>project-a</code>. I'm very close -- by specifying a <code>resolve.alias</code> in <code>project-a</code> that looks like <code>project-b: path.resolve(__dirname, '../project-b/entrypoint.js')</code> I can pull in what <code>entrypoint.js</code> offers. However, when Webpack attempts to resolve what <code>entrypoint</code> imports, it looks first in <code>project-b/node_modules</code>. This is a problem for two reasons: we use React, so this pulls in multiple copies of React (<code>project-a/node_modules/react</code> and <code>project-b/node_modules/react</code>), which React users know will break the UI, and similarly it pulls in multiple copies of any shared dependency, of which there are many, leading to a considerable amount of otherwise benign bloat in the Webpack artifact of <code>project-a</code>.</p>
  
  <p>My hunch is there must be a way to tell webpack to, when resolving imports in <code>project-b</code>, first look in <code>project-a</code> and failing that go ahead and look in <code>project-b</code>. This way it'll first look in <code>project-a/node_modules</code> for <code>react</code> whether the import statement is in <code>project-a</code> or <code>project-b</code>, leading to only <code>project-a/node_modules</code> copies of shared dependencies in <code>project-a</code>'s artifact, while successfully allowing unique <code>project-b</code> dependencies / components to be resolved. I've played around a bunch with <code>resolve.root</code>, <code>resolve.modulesDirectories</code>, and <code>resolve.fallback</code>, but haven't been able to achieve what I want. </p>
  
  <p>Any ideas?</p>