<p dir="auto">I haven't tried it yet, but does webpack reduce dependencies according to the package version? So if a module with the same version number is included from two different directories, e.g. <code class="notranslate">A/node_modules/underscore@1.x</code> and <code class="notranslate">B/node_modules/underscore@1.x</code>, webpack should include it only once into the bundle.</p>
<p dir="auto">It would be even better if webpack includes only one version as long as the major version of those two dependencies don't differ. So if <code class="notranslate">myLib1</code> depends on <code class="notranslate">underscore@1.1.3</code> and <code class="notranslate">myLib2</code> depends on <code class="notranslate">underscore@1.0.2</code>, webpack should include only <code class="notranslate">underscore@1.1.3</code> because - according to <a href="http://semver.org/" rel="nofollow">semver</a> - it won't break <code class="notranslate">myLib2</code>. Maybe this should be opt-in as it is potential risky.</p>
<p dir="auto">In any case webpack should log a warning if two versions of the same module are included.</p>
<p dir="auto">Hi <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sokra/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/sokra">@sokra</a></p>
<p dir="auto">When I try to require('jquery'), which is a jam module installed under web_modules, I always get the following message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- Serving static content.
- dev-server on port 8081.
&gt; Open http://localhost:8081/ in your browser.


Error: watch ENOENT
    at errnoException (fs.js:806:11)
    at FSWatcher.start (fs.js:837:11)
    at Object.fs.watch (fs.js:861:11)
    at module.exports (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:223:23)
    at Array.forEach (native)
    at EventEmitter.&lt;anonymous&gt; (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:222:19)
    at EventEmitter.emit (events.js:123:20)
    at writingFinished (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:522:19)
    at /Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:379:30
    at buildTree (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/buildDeps.js:103:3)
Hash: 4732db73d220259503822d5a079cf898
Compile Time: 677ms
Chunks: 1
Modules: 6
Modules including duplicates: 6
Modules first chunk: 6

 &lt;id&gt;    &lt;size&gt;  &lt;filename&gt;
dev.bundle.js
    0        11  ./_template/entry.js [caching]
    1        45  ./app/app.js [caching]
    2    259828  ./app/web_modules/jquery/jquery.js [caching]
    3       533  (webpack)/buildin/__webpack_amd_define.js [caching]
    4       428  (webpack)/buildin/__webpack_amd_require.js [caching]
    5        24  (webpack)/buildin/__webpack_options_amd.loader.js!(webpack)/buildin/__webpack_options_amd.loader.js [caching]
webpack: bundle is now VALID.
"><pre class="notranslate"><code class="notranslate">- Serving static content.
- dev-server on port 8081.
&gt; Open http://localhost:8081/ in your browser.


Error: watch ENOENT
    at errnoException (fs.js:806:11)
    at FSWatcher.start (fs.js:837:11)
    at Object.fs.watch (fs.js:861:11)
    at module.exports (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:223:23)
    at Array.forEach (native)
    at EventEmitter.&lt;anonymous&gt; (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:222:19)
    at EventEmitter.emit (events.js:123:20)
    at writingFinished (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:522:19)
    at /Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/webpack.js:379:30
    at buildTree (/Users/karlvanrompaey/Documents/apps/experiments/webpack/jam-app/node_modules/webpack/lib/buildDeps.js:103:3)
Hash: 4732db73d220259503822d5a079cf898
Compile Time: 677ms
Chunks: 1
Modules: 6
Modules including duplicates: 6
Modules first chunk: 6

 &lt;id&gt;    &lt;size&gt;  &lt;filename&gt;
dev.bundle.js
    0        11  ./_template/entry.js [caching]
    1        45  ./app/app.js [caching]
    2    259828  ./app/web_modules/jquery/jquery.js [caching]
    3       533  (webpack)/buildin/__webpack_amd_define.js [caching]
    4       428  (webpack)/buildin/__webpack_amd_require.js [caching]
    5        24  (webpack)/buildin/__webpack_options_amd.loader.js!(webpack)/buildin/__webpack_options_amd.loader.js [caching]
webpack: bundle is now VALID.

</code></pre></div>
<p dir="auto">Jquery seems to be correctly bundled in the app and the server also works, but, I always get an error message related to watch and I am not sure whether it is save to ignore this message !!! For sure the message should not be there :-)</p>
<p dir="auto">My setup as as follows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="wpt create jam-app
cd jam-app
npm install"><pre class="notranslate"><code class="notranslate">wpt create jam-app
cd jam-app
npm install
</code></pre></div>
<p dir="auto">Now add jam-dependencies to package.json</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    &quot;jam&quot;: {
        &quot;packageDir&quot;: &quot;app/web_modules&quot;,
        &quot;baseUrl&quot;: &quot;app&quot;,
        &quot;dependencies&quot;: {
            &quot;jquery&quot;: &quot;1.8.0&quot;,
            &quot;bootstrap&quot;: &quot;2.1.1-jam.1&quot;
        }
    },
"><pre class="notranslate"><code class="notranslate">    "jam": {
        "packageDir": "app/web_modules",
        "baseUrl": "app",
        "dependencies": {
            "jquery": "1.8.0",
            "bootstrap": "2.1.1-jam.1"
        }
    },

</code></pre></div>
<p dir="auto">Then run:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="jam install
dev-server.sh"><pre class="notranslate"><code class="notranslate">jam install
dev-server.sh
</code></pre></div>
<p dir="auto">And now the error messages start to appear</p>