title: How to organize large React application in multiple node modules using Webpack 4
body: <p>We have a large React application bundled with Webpack4. It's comprised of several smaller applications and services, each one isolated behind its own URL prefix. Those services share a common layout, several React components and a main menu.</p>
  
  <pre><code>https://largeapp.test/service1
  https://largeapp.test/service2
  </code></pre>
  
  <p>At the moment, the source code for each service is placed in its own directory below the main src/services directory:</p>
  
  <pre><code>largeapp/
      package.json
      webpack.config.js
      src/
          services/
              service1/
                  ...
              service2/
                  ...
  </code></pre>
  
  <p>We want to refactor the code to manage the main application and each service as npm packages, each one with its own git repo:</p>
  
  <pre><code>@largeapp/main/
      .git/
      package.json
      webpack.config.js
      src/
  
  @largeapp/service1/
      .git/
      package.json
      webpack.config.js
      src/
  
  @largeapp/service2/
      .git/
      package.json
      webpack.config.js
      src/
  </code></pre>
  
  <p>Each package will export some metadata (name, description, icon, url key) so we can build a dashboard with links to each services, and one or more React components:</p>
  
  <pre><code>export {
      metadata,
      Main,
      Sidebar
  }
  </code></pre>
  
  <p>We have no experience at organizing such a large application that way, so we have some doubts:</p>
  
  <ol>
  <li><p>Shared packages: all our packages should share same versions of React and some other packages. Is using externals the best approach?</p></li>
  <li><p>Watch for changes in dependent packages. At development time we want to hot reload the app when something change, doesn't matter wether the change happens in the main package or in the service package. Maybe there's some approach based on using <code>npm link</code> to package folder? Two webpack watch processes dependent in some way?</p></li>
  </ol>