title: How to achieve single instance of dependency across multiple webpack projects?
body: <p>I have a project that consists of a React app and a React Component Library.  (both of which are my own code).  The app and library are two separate packages with their own package.json and webpack based build system.  The app imports the library and uses React components from it.</p>
  
  <p>Both the app and the lib use react-router.  I am encountering a problem when I mount a component from the lib, which uses react-router, in my app.  I get the error "Error: Invariant failed: You should not use <code>&lt;Route&gt;</code> outside a <code>&lt;Router&gt;</code>"</p>
  
  <p>However the <code>&lt;Route&gt;</code> component actually is contained within a <code>&lt;Router&gt;</code> component.  </p>
  
  <p>I think the problem is the <code>&lt;Router&gt;</code> is rendered by app and the <code>&lt;Route&gt;</code> is rendered within the lib, and that each is using a different instance of the react-router context.</p>
  
  <p>I tested this theory by importing <code>&lt;Route&gt;</code> in both the app and the lib and using console.log to output the Route component to the console.  </p>
  
  <p>When I checked the two logs I found that each logged Route was a different instance.  I.e. Route from app !== Route from lib and I think this is why react-router is complaining.</p>
  
  <p>How can I configure webpack to ensure that both the app and the lib are using the same instance of react-router?</p>