In Webpack, how can an exports file not import everything it exports?
<p>I have a project that is divided into "modules".</p>

<p>Each module has an <strong><em>exports file</em></strong> that exports multiple files from the module.</p>

<p>By convention, we only require what is exposed in a module.</p>

<p>For example if I have the "Top Bar" and "Workspace" modules and they need to communicate, "Top Bar" exposes <strong>Only</strong> index.js and "Workspace" requires the desired part of the "Top Bar" from it:</p>

<p>TopBar/index.js:</p>

<pre><code>export TopBarComponent from './components/TopBarComponent'

export SomethingElse from './service/SomethingElse'
</code></pre>

<p>Workspace/components/Workspace.js:</p>

<pre><code>import {TopBarComponent} from 'TopBarComponent'
....
</code></pre>

<p>While this way the project is very modular, my problem is that when "Workspace" requires "TopBarComponent", "SomethingElse" gets imported along the way.</p>

<p>Any Ideas on how to prevent it with the assumption index.js of each module is an export file and only has export lines?</p>