<p dir="auto">To reproduce, just clone <a href="https://g.trusktr.io/trusktr/webpack-test.git" rel="nofollow">https://g.trusktr.io/trusktr/webpack-test.git</a>, then run</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="npm install
webpack"><pre class="notranslate">npm install
webpack</pre></div>
<p dir="auto">then look at <code class="notranslate">./built/shared-modules.js</code> to notice that it doesn't contain any shared modules.</p>
<h3 dir="auto">Problem:</h3>
<p dir="auto">Seems like the problem is that npm installs local packages, those listed with file:path format, in such a way that Webpack doesn't detect shared/common modules?</p>
<h3 dir="auto">Details:</h3>
<p dir="auto">I have a tree that looks like this after running Webpack. The <code class="notranslate">built</code> folder is the <code class="notranslate">output</code> folder:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=".
├── built
│   ├── __app__
│   │   └── client
│   │       └── app.module.js
│   ├── shared-modules.js
│   ├── trusktr_lib2
│   │   └── module.js
│   └── trusktr_scratchpaper
│       ├── client.module.js
│       └── foo
│           └── bar.module.js
├── node_modules
│   ├── rocket_module
│   │   └── package.json
│   ├── trusktr_lib2
│   │   ├── module.js
│   │   ├── node_modules
│   │   │   ├── lower-case
│   │   │   │   ├── LICENSE
│   │   │   │   ├── README.md
│   │   │   │   ├── lower-case.js
│   │   │   │   └── package.json
│   │   │   └── upper-case
│   │   │       ├── LICENSE
│   │   │       ├── README.md
│   │   │       ├── package.json
│   │   │       └── upper-case.js
│   │   └── package.json
│   └── trusktr_scratchpaper
│       ├── client.module.js
│       ├── foo
│       │   └── bar.module.js
│       ├── node_modules
│       │   └── upper-case
│       │       ├── LICENSE
│       │       ├── README.md
│       │       ├── package.json
│       │       └── upper-case.js
│       └── package.json
├── package.json
└── packages
    ├── __app__
    │   └── client
    │       └── app.module.js
    ├── rocket_module
    │   └── package.json
    ├── trusktr_lib2
    │   ├── module.js
    │   └── package.json
    └── trusktr_scratchpaper
        ├── client.module.js
        ├── foo
        │   └── bar.module.js
        └── package.json"><pre class="notranslate"><code class="notranslate">.
├── built
│   ├── __app__
│   │   └── client
│   │       └── app.module.js
│   ├── shared-modules.js
│   ├── trusktr_lib2
│   │   └── module.js
│   └── trusktr_scratchpaper
│       ├── client.module.js
│       └── foo
│           └── bar.module.js
├── node_modules
│   ├── rocket_module
│   │   └── package.json
│   ├── trusktr_lib2
│   │   ├── module.js
│   │   ├── node_modules
│   │   │   ├── lower-case
│   │   │   │   ├── LICENSE
│   │   │   │   ├── README.md
│   │   │   │   ├── lower-case.js
│   │   │   │   └── package.json
│   │   │   └── upper-case
│   │   │       ├── LICENSE
│   │   │       ├── README.md
│   │   │       ├── package.json
│   │   │       └── upper-case.js
│   │   └── package.json
│   └── trusktr_scratchpaper
│       ├── client.module.js
│       ├── foo
│       │   └── bar.module.js
│       ├── node_modules
│       │   └── upper-case
│       │       ├── LICENSE
│       │       ├── README.md
│       │       ├── package.json
│       │       └── upper-case.js
│       └── package.json
├── package.json
└── packages
    ├── __app__
    │   └── client
    │       └── app.module.js
    ├── rocket_module
    │   └── package.json
    ├── trusktr_lib2
    │   ├── module.js
    │   └── package.json
    └── trusktr_scratchpaper
        ├── client.module.js
        ├── foo
        │   └── bar.module.js
        └── package.json
</code></pre></div>
<p dir="auto">Everything in the <code class="notranslate">packages</code> folder is treated as a local node_module and listed in the root <code class="notranslate">package.json</code> using <code class="notranslate">file:path</code> notation:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;dependencies&quot;: {
        &quot;rocket_module&quot;: &quot;file:./packages/rocket_module&quot;,
        &quot;trusktr_lib2&quot;: &quot;file:./packages/trusktr_lib2&quot;,
        &quot;trusktr_scratchpaper&quot;: &quot;file:./packages/trusktr_scratchpaper&quot;
    }
}"><pre class="notranslate"><span class="pl-kos">{</span>
    <span class="pl-s">"dependencies"</span>: <span class="pl-kos">{</span>
        <span class="pl-s">"rocket_module"</span>: <span class="pl-s">"file:./packages/rocket_module"</span><span class="pl-kos">,</span>
        <span class="pl-s">"trusktr_lib2"</span>: <span class="pl-s">"file:./packages/trusktr_lib2"</span><span class="pl-kos">,</span>
        <span class="pl-s">"trusktr_scratchpaper"</span>: <span class="pl-s">"file:./packages/trusktr_scratchpaper"</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">I then run <code class="notranslate">npm install</code> in the root folder, which places the local packages into the top-level node_modules folder:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="├── node_modules
│   ├── rocket_module
│   │   └── package.json
│   ├── trusktr_lib2
│   │   ├── module.js
│   │   ├── node_modules
│   │   │   ├── lower-case
│   │   │   │   ├── LICENSE
│   │   │   │   ├── README.md
│   │   │   │   ├── lower-case.js
│   │   │   │   └── package.json
│   │   │   └── upper-case
│   │   │       ├── LICENSE
│   │   │       ├── README.md
│   │   │       ├── package.json
│   │   │       └── upper-case.js
│   │   └── package.json
│   └── trusktr_scratchpaper
│       ├── client.module.js
│       ├── foo
│       │   └── bar.module.js
│       ├── node_modules
│       │   └── upper-case
│       │       ├── LICENSE
│       │       ├── README.md
│       │       ├── package.json
│       │       └── upper-case.js
│       └── package.json"><pre class="notranslate"><code class="notranslate">├── node_modules
│   ├── rocket_module
│   │   └── package.json
│   ├── trusktr_lib2
│   │   ├── module.js
│   │   ├── node_modules
│   │   │   ├── lower-case
│   │   │   │   ├── LICENSE
│   │   │   │   ├── README.md
│   │   │   │   ├── lower-case.js
│   │   │   │   └── package.json
│   │   │   └── upper-case
│   │   │       ├── LICENSE
│   │   │       ├── README.md
│   │   │       ├── package.json
│   │   │       └── upper-case.js
│   │   └── package.json
│   └── trusktr_scratchpaper
│       ├── client.module.js
│       ├── foo
│       │   └── bar.module.js
│       ├── node_modules
│       │   └── upper-case
│       │       ├── LICENSE
│       │       ├── README.md
│       │       ├── package.json
│       │       └── upper-case.js
│       └── package.json
</code></pre></div>
<p dir="auto">We can see that each package contains it's own <code class="notranslate">node_modules</code> folder, and there are duplicate dependencies, like <code class="notranslate">upper-case</code>, but the duplicates are of the same version.</p>
<p dir="auto">Now, I'm adding each of those node_modules folders to webpack.config.js, so it looks like this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="module.exports = {
    entry: {
        &quot;__app__/client/app.module.js&quot;: &quot;./packages/__app__/client/app.module.js&quot;,
        &quot;trusktr_lib2/module.js&quot;: &quot;./packages/trusktr_lib2/module.js&quot;,
        &quot;trusktr_scratchpaper/client.module.js&quot;: &quot;./packages/trusktr_scratchpaper/client.module.js&quot;,
        &quot;trusktr_scratchpaper/foo/bar.module.js&quot;: &quot;./packages/trusktr_scratchpaper/foo/bar.module.js&quot;
    },
    output: {
        path: &quot;/root/built&quot;
        filename: &quot;[name]&quot;,
    },
    plugins: [ new webpack.optimize.CommonsChunkPlugin(&quot;shared-modules.js&quot;) ],
    resolve: {
        fallback: [
            &quot;/root/node_modules/trusktr_lib2/node_modules&quot;,
            &quot;/root/node_modules/trusktr_scratchpaper/node_modules&quot;
        ]
    }
    module: {
        loaders: [
            { test: /\.css$/, loader: &quot;style!css&quot; }
        ]
    },
}"><pre class="notranslate"><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">entry</span>: <span class="pl-kos">{</span>
        <span class="pl-s">"__app__/client/app.module.js"</span>: <span class="pl-s">"./packages/__app__/client/app.module.js"</span><span class="pl-kos">,</span>
        <span class="pl-s">"trusktr_lib2/module.js"</span>: <span class="pl-s">"./packages/trusktr_lib2/module.js"</span><span class="pl-kos">,</span>
        <span class="pl-s">"trusktr_scratchpaper/client.module.js"</span>: <span class="pl-s">"./packages/trusktr_scratchpaper/client.module.js"</span><span class="pl-kos">,</span>
        <span class="pl-s">"trusktr_scratchpaper/foo/bar.module.js"</span>: <span class="pl-s">"./packages/trusktr_scratchpaper/foo/bar.module.js"</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c1">output</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">path</span>: <span class="pl-s">"/root/built"</span>
        <span class="pl-s1">filename</span>: <span class="pl-s">"[name]"</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c1">plugins</span>: <span class="pl-kos">[</span> <span class="pl-k">new</span> <span class="pl-s1">webpack</span><span class="pl-kos">.</span><span class="pl-c1">optimize</span><span class="pl-kos">.</span><span class="pl-c1">CommonsChunkPlugin</span><span class="pl-kos">(</span><span class="pl-s">"shared-modules.js"</span><span class="pl-kos">)</span> <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-c1">resolve</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">fallback</span>: <span class="pl-kos">[</span>
            <span class="pl-s">"/root/node_modules/trusktr_lib2/node_modules"</span><span class="pl-kos">,</span>
            <span class="pl-s">"/root/node_modules/trusktr_scratchpaper/node_modules"</span>
        <span class="pl-kos">]</span>
    <span class="pl-kos">}</span>
    <span class="pl-smi">module</span>: <span class="pl-kos">{</span>
        <span class="pl-s1">loaders</span>: <span class="pl-kos">[</span>
            <span class="pl-kos">{</span> <span class="pl-c1">test</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-cce">\.</span>css<span class="pl-cce">$</span><span class="pl-c1">/</span></span><span class="pl-kos">,</span> <span class="pl-c1">loader</span>: <span class="pl-s">"style!css"</span> <span class="pl-kos">}</span>
        <span class="pl-kos">]</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Now when I run <code class="notranslate">webpack</code> it compiles the the files into the <code class="notranslate">built</code> folder. The output <code class="notranslate">shared-modules.js</code> file looks like this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/******/ (function(modules) { // webpackBootstrap
/******/    // install a JSONP callback for chunk loading
/******/    var parentJsonpFunction = window[&quot;webpackJsonp&quot;];
/******/    window[&quot;webpackJsonp&quot;] = function webpackJsonpCallback(chunkIds, moreModules) {
/******/        // add &quot;moreModules&quot; to the modules object,
/******/        // then flag all &quot;chunkIds&quot; as loaded and fire callback
/******/        var moduleId, chunkId, i = 0, callbacks = [];
/******/        for(;i &lt; chunkIds.length; i++) {
/******/            chunkId = chunkIds[i];
/******/            if(installedChunks[chunkId])
/******/                callbacks.push.apply(callbacks, installedChunks[chunkId]);
/******/            installedChunks[chunkId] = 0;
/******/        }
/******/        for(moduleId in moreModules) {
/******/            modules[moduleId] = moreModules[moduleId];
/******/        }
/******/        if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);
/******/        while(callbacks.length)
/******/            callbacks.shift().call(null, __webpack_require__);
/******/        if(moreModules[0]) {
/******/            installedModules[0] = 0;
/******/            return __webpack_require__(0);
/******/        }
/******/    };

/******/    // The module cache
/******/    var installedModules = {};

/******/    // object to store loaded and loading chunks
/******/    // &quot;0&quot; means &quot;already loaded&quot;
/******/    // Array means &quot;loading&quot;, array contains callbacks
/******/    var installedChunks = {
/******/        4:0
/******/    };

/******/    // The require function
/******/    function __webpack_require__(moduleId) {

/******/        // Check if module is in cache
/******/        if(installedModules[moduleId])
/******/            return installedModules[moduleId].exports;

/******/        // Create a new module (and put it into the cache)
/******/        var module = installedModules[moduleId] = {
/******/            exports: {},
/******/            id: moduleId,
/******/            loaded: false
/******/        };

/******/        // Execute the module function
/******/        modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/        // Flag the module as loaded
/******/        module.loaded = true;

/******/        // Return the exports of the module
/******/        return module.exports;
/******/    }

/******/    // This file contains only the entry chunk.
/******/    // The chunk loading function for additional chunks
/******/    __webpack_require__.e = function requireEnsure(chunkId, callback) {
/******/        // &quot;0&quot; is the signal for &quot;already loaded&quot;
/******/        if(installedChunks[chunkId] === 0)
/******/            return callback.call(null, __webpack_require__);

/******/        // an array means &quot;currently loading&quot;.
/******/        if(installedChunks[chunkId] !== undefined) {
/******/            installedChunks[chunkId].push(callback);
/******/        } else {
/******/            // start chunk loading
/******/            installedChunks[chunkId] = [callback];
/******/            var head = document.getElementsByTagName('head')[0];
/******/            var script = document.createElement('script');
/******/            script.type = 'text/javascript';
/******/            script.charset = 'utf-8';
/******/            script.async = true;

/******/            script.src = __webpack_require__.p + &quot;&quot; + chunkId + &quot;.&quot; + ({&quot;0&quot;:&quot;__app__/client/app.module.js&quot;,&quot;1&quot;:&quot;trusktr_scratchpaper/client.module.js&quot;,&quot;2&quot;:&quot;trusktr_scratchpaper/foo/bar.module.js&quot;,&quot;3&quot;:&quot;trusktr_lib2/module.js&quot;}[chunkId]||chunkId) + &quot;&quot;;
/******/            head.appendChild(script);
/******/        }
/******/    };

/******/    // expose the modules object (__webpack_modules__)
/******/    __webpack_require__.m = modules;

/******/    // expose the module cache
/******/    __webpack_require__.c = installedModules;

/******/    // __webpack_public_path__
/******/    __webpack_require__.p = &quot;&quot;;
/******/ })
/************************************************************************/
/******/ ([]);"><pre class="notranslate"><span class="pl-c">/******/</span> <span class="pl-kos">(</span><span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">modules</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-c">// webpackBootstrap</span>
<span class="pl-c">/******/</span>    <span class="pl-c">// install a JSONP callback for chunk loading</span>
<span class="pl-c">/******/</span>    <span class="pl-k">var</span> <span class="pl-s1">parentJsonpFunction</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">[</span><span class="pl-s">"webpackJsonp"</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>    <span class="pl-smi">window</span><span class="pl-kos">[</span><span class="pl-s">"webpackJsonp"</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">webpackJsonpCallback</span><span class="pl-kos">(</span><span class="pl-s1">chunkIds</span><span class="pl-kos">,</span> <span class="pl-s1">moreModules</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>        <span class="pl-c">// add "moreModules" to the modules object,</span>
<span class="pl-c">/******/</span>        <span class="pl-c">// then flag all "chunkIds" as loaded and fire callback</span>
<span class="pl-c">/******/</span>        <span class="pl-k">var</span> <span class="pl-s1">moduleId</span><span class="pl-kos">,</span> <span class="pl-s1">chunkId</span><span class="pl-kos">,</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s1">callbacks</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-k">for</span><span class="pl-kos">(</span><span class="pl-kos">;</span><span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">chunkIds</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">chunkId</span> <span class="pl-c1">=</span> <span class="pl-s1">chunkIds</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span><span class="pl-kos">)</span>
<span class="pl-c">/******/</span>                <span class="pl-s1">callbacks</span><span class="pl-kos">.</span><span class="pl-c1">push</span><span class="pl-kos">.</span><span class="pl-en">apply</span><span class="pl-kos">(</span><span class="pl-s1">callbacks</span><span class="pl-kos">,</span> <span class="pl-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-kos">}</span>
<span class="pl-c">/******/</span>        <span class="pl-k">for</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span> <span class="pl-k">in</span> <span class="pl-s1">moreModules</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">modules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">moreModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-kos">}</span>
<span class="pl-c">/******/</span>        <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">parentJsonpFunction</span><span class="pl-kos">)</span> <span class="pl-s1">parentJsonpFunction</span><span class="pl-kos">(</span><span class="pl-s1">chunkIds</span><span class="pl-kos">,</span> <span class="pl-s1">moreModules</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-k">while</span><span class="pl-kos">(</span><span class="pl-s1">callbacks</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">)</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">callbacks</span><span class="pl-kos">.</span><span class="pl-en">shift</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">moreModules</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-k">return</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-kos">}</span>
<span class="pl-c">/******/</span>    <span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>    <span class="pl-c">// The module cache</span>
<span class="pl-c">/******/</span>    <span class="pl-k">var</span> <span class="pl-s1">installedModules</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>    <span class="pl-c">// object to store loaded and loading chunks</span>
<span class="pl-c">/******/</span>    <span class="pl-c">// "0" means "already loaded"</span>
<span class="pl-c">/******/</span>    <span class="pl-c">// Array means "loading", array contains callbacks</span>
<span class="pl-c">/******/</span>    <span class="pl-k">var</span> <span class="pl-s1">installedChunks</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>        <span class="pl-c1">4</span>:<span class="pl-c1">0</span>
<span class="pl-c">/******/</span>    <span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>    <span class="pl-c">// The require function</span>
<span class="pl-c">/******/</span>    <span class="pl-k">function</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

<span class="pl-c">/******/</span>        <span class="pl-c">// Check if module is in cache</span>
<span class="pl-c">/******/</span>        <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">)</span>
<span class="pl-c">/******/</span>            <span class="pl-k">return</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>        <span class="pl-c">// Create a new module (and put it into the cache)</span>
<span class="pl-c">/******/</span>        <span class="pl-k">var</span> <span class="pl-s1">module</span> <span class="pl-c1">=</span> <span class="pl-s1">installedModules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>            <span class="pl-c1">exports</span>: <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-c">/******/</span>            <span class="pl-c1">id</span>: <span class="pl-s1">moduleId</span><span class="pl-kos">,</span>
<span class="pl-c">/******/</span>            <span class="pl-c1">loaded</span>: <span class="pl-c1">false</span>
<span class="pl-c">/******/</span>        <span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>        <span class="pl-c">// Execute the module function</span>
<span class="pl-c">/******/</span>        <span class="pl-s1">modules</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>        <span class="pl-c">// Flag the module as loaded</span>
<span class="pl-c">/******/</span>        <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">loaded</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>        <span class="pl-c">// Return the exports of the module</span>
<span class="pl-c">/******/</span>        <span class="pl-k">return</span> <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>    <span class="pl-kos">}</span>

<span class="pl-c">/******/</span>    <span class="pl-c">// This file contains only the entry chunk.</span>
<span class="pl-c">/******/</span>    <span class="pl-c">// The chunk loading function for additional chunks</span>
<span class="pl-c">/******/</span>    <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">e</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">requireEnsure</span><span class="pl-kos">(</span><span class="pl-s1">chunkId</span><span class="pl-kos">,</span> <span class="pl-s1">callback</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>        <span class="pl-c">// "0" is the signal for "already loaded"</span>
<span class="pl-c">/******/</span>        <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span><span class="pl-kos">)</span>
<span class="pl-c">/******/</span>            <span class="pl-k">return</span> <span class="pl-s1">callback</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>        <span class="pl-c">// an array means "currently loading".</span>
<span class="pl-c">/******/</span>        <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">callback</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
<span class="pl-c">/******/</span>            <span class="pl-c">// start chunk loading</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-s1">callback</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-k">var</span> <span class="pl-s1">head</span> <span class="pl-c1">=</span> <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">getElementsByTagName</span><span class="pl-kos">(</span><span class="pl-s">'head'</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-k">var</span> <span class="pl-s1">script</span> <span class="pl-c1">=</span> <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">createElement</span><span class="pl-kos">(</span><span class="pl-s">'script'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">script</span><span class="pl-kos">.</span><span class="pl-c1">type</span> <span class="pl-c1">=</span> <span class="pl-s">'text/javascript'</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">script</span><span class="pl-kos">.</span><span class="pl-c1">charset</span> <span class="pl-c1">=</span> <span class="pl-s">'utf-8'</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">script</span><span class="pl-kos">.</span><span class="pl-c1">async</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>            <span class="pl-s1">script</span><span class="pl-kos">.</span><span class="pl-c1">src</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-c1">p</span> <span class="pl-c1">+</span> <span class="pl-s">""</span> <span class="pl-c1">+</span> <span class="pl-s1">chunkId</span> <span class="pl-c1">+</span> <span class="pl-s">"."</span> <span class="pl-c1">+</span> <span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-s">"0"</span>:<span class="pl-s">"__app__/client/app.module.js"</span><span class="pl-kos">,</span><span class="pl-s">"1"</span>:<span class="pl-s">"trusktr_scratchpaper/client.module.js"</span><span class="pl-kos">,</span><span class="pl-s">"2"</span>:<span class="pl-s">"trusktr_scratchpaper/foo/bar.module.js"</span><span class="pl-kos">,</span><span class="pl-s">"3"</span>:<span class="pl-s">"trusktr_lib2/module.js"</span><span class="pl-kos">}</span><span class="pl-kos">[</span><span class="pl-s1">chunkId</span><span class="pl-kos">]</span><span class="pl-c1">||</span><span class="pl-s1">chunkId</span><span class="pl-kos">)</span> <span class="pl-c1">+</span> <span class="pl-s">""</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>            <span class="pl-s1">head</span><span class="pl-kos">.</span><span class="pl-en">appendChild</span><span class="pl-kos">(</span><span class="pl-s1">script</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span>        <span class="pl-kos">}</span>
<span class="pl-c">/******/</span>    <span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>    <span class="pl-c">// expose the modules object (__webpack_modules__)</span>
<span class="pl-c">/******/</span>    <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-c1">m</span> <span class="pl-c1">=</span> <span class="pl-s1">modules</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>    <span class="pl-c">// expose the module cache</span>
<span class="pl-c">/******/</span>    <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-c1">c</span> <span class="pl-c1">=</span> <span class="pl-s1">installedModules</span><span class="pl-kos">;</span>

<span class="pl-c">/******/</span>    <span class="pl-c">// __webpack_public_path__</span>
<span class="pl-c">/******/</span>    <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-c1">p</span> <span class="pl-c1">=</span> <span class="pl-s">""</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-c">/************************************************************************/</span>
<span class="pl-c">/******/</span> <span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">We can see that there's no common modules in this entry chunk made by the CommonsChunkPlugin. Instead, the modules are duplicated in the initial chunk files.</p>
<p dir="auto">Here's the <code class="notranslate">built/trusktr_lib2/module.js</code> file:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="webpackJsonp([3,4],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

    // Write your package code here!
    var lowercase = __webpack_require__(2)
    var uppercase = __webpack_require__(1)

    console.log(' --- ', lowercase('SHOULD BE LOWERCASE!'))
    console.log(' --- ', uppercase('Should be uppercase!'))


    Lib = {
        hello: function() {
            return 'Goodbye.'
        }
    } // ----------------------------------------------------------------------------------------------------------------------------------------------------


/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {

    /**
     * Special language-specific overrides.
     *
     * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
     *
     * @type {Object}
     */
    var LANGUAGES = {
      tr: {
        regexp: /[\u0069]/g,
        map: {
          '\u0069': '\u0130'
        }
      },
      az: {
        regexp: /[\u0069]/g,
        map: {
          '\u0069': '\u0130'
        }
      },
      lt: {
        regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g,
        map: {
          '\u0069\u0307': '\u0049',
          '\u006A\u0307': '\u004A',
          '\u012F\u0307': '\u012E',
          '\u0069\u0307\u0300': '\u00CC',
          '\u0069\u0307\u0301': '\u00CD',
          '\u0069\u0307\u0303': '\u0128'
        }
      }
    }

    /**
     * Upper case a string.
     *
     * @param  {String} str
     * @return {String}
     */
    module.exports = function (str, locale) {
      var lang = LANGUAGES[locale]

      str = str == null ? '' : String(str)

      if (lang) {
        str = str.replace(lang.regexp, function (m) { return lang.map[m] })
      }

      return str.toUpperCase()
    }


/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

    /**
     * Special language-specific overrides.
     *
     * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
     *
     * @type {Object}
     */
    var LANGUAGES = {
      tr: {
        regexp: /\u0130|\u0049|\u0049\u0307/g,
        map: {
          '\u0130': '\u0069',
          '\u0049': '\u0131',
          '\u0049\u0307': '\u0069'
        }
      },
      az: {
        regexp: /[\u0130]/g,
        map: {
          '\u0130': '\u0069',
          '\u0049': '\u0131',
          '\u0049\u0307': '\u0069'
        }
      },
      lt: {
        regexp: /[\u0049\u004A\u012E\u00CC\u00CD\u0128]/g,
        map: {
          '\u0049': '\u0069\u0307',
          '\u004A': '\u006A\u0307',
          '\u012E': '\u012F\u0307',
          '\u00CC': '\u0069\u0307\u0300',
          '\u00CD': '\u0069\u0307\u0301',
          '\u0128': '\u0069\u0307\u0303'
        }
      }
    }

    /**
     * Lowercase a string.
     *
     * @param  {String} str
     * @return {String}
     */
    module.exports = function (str, locale) {
      var lang = LANGUAGES[locale]

      str = str == null ? '' : String(str)

      if (lang) {
        str = str.replace(lang.regexp, function (m) { return lang.map[m] })
      }

      return str.toLowerCase()
    }


/***/ }
]);"><pre class="notranslate"><span class="pl-en">webpackJsonp</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-c1">3</span><span class="pl-kos">,</span><span class="pl-c1">4</span><span class="pl-kos">]</span><span class="pl-kos">,</span><span class="pl-kos">[</span>
<span class="pl-c">/* 0 */</span>
<span class="pl-c">/***/</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

    <span class="pl-c">// Write your package code here!</span>
    <span class="pl-k">var</span> <span class="pl-s1">lowercase</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-c1">2</span><span class="pl-kos">)</span>
    <span class="pl-k">var</span> <span class="pl-s1">uppercase</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span>

    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">' --- '</span><span class="pl-kos">,</span> <span class="pl-s1">lowercase</span><span class="pl-kos">(</span><span class="pl-s">'SHOULD BE LOWERCASE!'</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">' --- '</span><span class="pl-kos">,</span> <span class="pl-s1">uppercase</span><span class="pl-kos">(</span><span class="pl-s">'Should be uppercase!'</span><span class="pl-kos">)</span><span class="pl-kos">)</span>


    <span class="pl-v">Lib</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
        <span class="pl-en">hello</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">return</span> <span class="pl-s">'Goodbye.'</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">}</span> <span class="pl-c">// ----------------------------------------------------------------------------------------------------------------------------------------------------</span>


<span class="pl-c">/***/</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-c">/* 1 */</span>
<span class="pl-c">/***/</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Special language-specific overrides.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@type</span> {Object}</span>
<span class="pl-c">     */</span>
    <span class="pl-k">var</span> <span class="pl-c1">LANGUAGES</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
      <span class="pl-c1">tr</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0069<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0069'</span>: <span class="pl-s">'\u0130'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">az</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0069<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0069'</span>: <span class="pl-s">'\u0130'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">lt</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0069<span class="pl-cce">\u</span>006A<span class="pl-cce">\u</span>012F<span class="pl-kos">]</span><span class="pl-cce">\u</span>0307<span class="pl-c1">|</span><span class="pl-cce">\u</span>0069<span class="pl-cce">\u</span>0307<span class="pl-kos">[</span><span class="pl-cce">\u</span>0300<span class="pl-cce">\u</span>0301<span class="pl-cce">\u</span>0303<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0069\u0307'</span>: <span class="pl-s">'\u0049'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u006A\u0307'</span>: <span class="pl-s">'\u004A'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u012F\u0307'</span>: <span class="pl-s">'\u012E'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0069\u0307\u0300'</span>: <span class="pl-s">'\u00CC'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0069\u0307\u0301'</span>: <span class="pl-s">'\u00CD'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0069\u0307\u0303'</span>: <span class="pl-s">'\u0128'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Upper case a string.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span>  {<span class="pl-smi">String</span>} str</span>
<span class="pl-c">     * <span class="pl-k">@return</span> {<span class="pl-smi">String</span>}</span>
<span class="pl-c">     */</span>
    <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-en">exports</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">str</span><span class="pl-kos">,</span> <span class="pl-s1">locale</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">var</span> <span class="pl-s1">lang</span> <span class="pl-c1">=</span> <span class="pl-c1">LANGUAGES</span><span class="pl-kos">[</span><span class="pl-s1">locale</span><span class="pl-kos">]</span>

      <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s1">str</span> <span class="pl-c1">==</span> <span class="pl-c1">null</span> ? <span class="pl-s">''</span> : <span class="pl-v">String</span><span class="pl-kos">(</span><span class="pl-s1">str</span><span class="pl-kos">)</span>

      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">lang</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s1">str</span><span class="pl-kos">.</span><span class="pl-en">replace</span><span class="pl-kos">(</span><span class="pl-s1">lang</span><span class="pl-kos">.</span><span class="pl-c1">regexp</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">m</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">lang</span><span class="pl-kos">.</span><span class="pl-c1">map</span><span class="pl-kos">[</span><span class="pl-s1">m</span><span class="pl-kos">]</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>
      <span class="pl-kos">}</span>

      <span class="pl-k">return</span> <span class="pl-s1">str</span><span class="pl-kos">.</span><span class="pl-en">toUpperCase</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>


<span class="pl-c">/***/</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-c">/* 2 */</span>
<span class="pl-c">/***/</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Special language-specific overrides.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@type</span> {Object}</span>
<span class="pl-c">     */</span>
    <span class="pl-k">var</span> <span class="pl-c1">LANGUAGES</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
      <span class="pl-c1">tr</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-cce">\u</span>0130<span class="pl-c1">|</span><span class="pl-cce">\u</span>0049<span class="pl-c1">|</span><span class="pl-cce">\u</span>0049<span class="pl-cce">\u</span>0307<span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0130'</span>: <span class="pl-s">'\u0069'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0049'</span>: <span class="pl-s">'\u0131'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0049\u0307'</span>: <span class="pl-s">'\u0069'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">az</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0130<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0130'</span>: <span class="pl-s">'\u0069'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0049'</span>: <span class="pl-s">'\u0131'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0049\u0307'</span>: <span class="pl-s">'\u0069'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">lt</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0049<span class="pl-cce">\u</span>004A<span class="pl-cce">\u</span>012E<span class="pl-cce">\u</span>00CC<span class="pl-cce">\u</span>00CD<span class="pl-cce">\u</span>0128<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0049'</span>: <span class="pl-s">'\u0069\u0307'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u004A'</span>: <span class="pl-s">'\u006A\u0307'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u012E'</span>: <span class="pl-s">'\u012F\u0307'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u00CC'</span>: <span class="pl-s">'\u0069\u0307\u0300'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u00CD'</span>: <span class="pl-s">'\u0069\u0307\u0301'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0128'</span>: <span class="pl-s">'\u0069\u0307\u0303'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Lowercase a string.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span>  {<span class="pl-smi">String</span>} str</span>
<span class="pl-c">     * <span class="pl-k">@return</span> {<span class="pl-smi">String</span>}</span>
<span class="pl-c">     */</span>
    <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-en">exports</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">str</span><span class="pl-kos">,</span> <span class="pl-s1">locale</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">var</span> <span class="pl-s1">lang</span> <span class="pl-c1">=</span> <span class="pl-c1">LANGUAGES</span><span class="pl-kos">[</span><span class="pl-s1">locale</span><span class="pl-kos">]</span>

      <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s1">str</span> <span class="pl-c1">==</span> <span class="pl-c1">null</span> ? <span class="pl-s">''</span> : <span class="pl-v">String</span><span class="pl-kos">(</span><span class="pl-s1">str</span><span class="pl-kos">)</span>

      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">lang</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s1">str</span><span class="pl-kos">.</span><span class="pl-en">replace</span><span class="pl-kos">(</span><span class="pl-s1">lang</span><span class="pl-kos">.</span><span class="pl-c1">regexp</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">m</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">lang</span><span class="pl-kos">.</span><span class="pl-c1">map</span><span class="pl-kos">[</span><span class="pl-s1">m</span><span class="pl-kos">]</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>
      <span class="pl-kos">}</span>

      <span class="pl-k">return</span> <span class="pl-s1">str</span><span class="pl-kos">.</span><span class="pl-en">toLowerCase</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>


<span class="pl-c">/***/</span> <span class="pl-kos">}</span>
<span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">and here's the <code class="notranslate">built/trusktr_scratchpaper/client.module.js</code> file:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="webpackJsonp([1,4],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

    // Write your package code here!
    var uppercase = __webpack_require__(1)
    var local = __webpack_require__(!(function webpackMissingModule() { var e = new Error(&quot;Cannot find module \&quot;./local\&quot;&quot;); e.code = 'MODULE_NOT_FOUND'; throw e; }()))

    console.log(' --- ', uppercase('Should be uppercase! (scratchpaper)'))
    console.log(' --- local import: ', local)

    // a Meteor export that other packages can use if they depend on this package.
    Lib = {
        hello: function() {
            return 'Hello.'
        }
    }



/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {

    /**
     * Special language-specific overrides.
     *
     * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
     *
     * @type {Object}
     */
    var LANGUAGES = {
      tr: {
        regexp: /[\u0069]/g,
        map: {
          '\u0069': '\u0130'
        }
      },
      az: {
        regexp: /[\u0069]/g,
        map: {
          '\u0069': '\u0130'
        }
      },
      lt: {
        regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g,
        map: {
          '\u0069\u0307': '\u0049',
          '\u006A\u0307': '\u004A',
          '\u012F\u0307': '\u012E',
          '\u0069\u0307\u0300': '\u00CC',
          '\u0069\u0307\u0301': '\u00CD',
          '\u0069\u0307\u0303': '\u0128'
        }
      }
    }

    /**
     * Upper case a string.
     *
     * @param  {String} str
     * @return {String}
     */
    module.exports = function (str, locale) {
      var lang = LANGUAGES[locale]

      str = str == null ? '' : String(str)

      if (lang) {
        str = str.replace(lang.regexp, function (m) { return lang.map[m] })
      }

      return str.toUpperCase()
    }


/***/ }
]);"><pre class="notranslate"><span class="pl-en">webpackJsonp</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-c1">1</span><span class="pl-kos">,</span><span class="pl-c1">4</span><span class="pl-kos">]</span><span class="pl-kos">,</span><span class="pl-kos">[</span>
<span class="pl-c">/* 0 */</span>
<span class="pl-c">/***/</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

    <span class="pl-c">// Write your package code here!</span>
    <span class="pl-k">var</span> <span class="pl-s1">uppercase</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span>
    <span class="pl-k">var</span> <span class="pl-s1">local</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-en">webpackMissingModule</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">var</span> <span class="pl-s1">e</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Error</span><span class="pl-kos">(</span><span class="pl-s">"Cannot find module \"./local\""</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">code</span> <span class="pl-c1">=</span> <span class="pl-s">'MODULE_NOT_FOUND'</span><span class="pl-kos">;</span> <span class="pl-k">throw</span> <span class="pl-s1">e</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">)</span>

    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">' --- '</span><span class="pl-kos">,</span> <span class="pl-s1">uppercase</span><span class="pl-kos">(</span><span class="pl-s">'Should be uppercase! (scratchpaper)'</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">' --- local import: '</span><span class="pl-kos">,</span> <span class="pl-s1">local</span><span class="pl-kos">)</span>

    <span class="pl-c">// a Meteor export that other packages can use if they depend on this package.</span>
    <span class="pl-v">Lib</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
        <span class="pl-en">hello</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">return</span> <span class="pl-s">'Hello.'</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>



<span class="pl-c">/***/</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-c">/* 1 */</span>
<span class="pl-c">/***/</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Special language-specific overrides.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@type</span> {Object}</span>
<span class="pl-c">     */</span>
    <span class="pl-k">var</span> <span class="pl-c1">LANGUAGES</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
      <span class="pl-c1">tr</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0069<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0069'</span>: <span class="pl-s">'\u0130'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">az</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0069<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0069'</span>: <span class="pl-s">'\u0130'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">lt</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">regexp</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-kos">[</span><span class="pl-cce">\u</span>0069<span class="pl-cce">\u</span>006A<span class="pl-cce">\u</span>012F<span class="pl-kos">]</span><span class="pl-cce">\u</span>0307<span class="pl-c1">|</span><span class="pl-cce">\u</span>0069<span class="pl-cce">\u</span>0307<span class="pl-kos">[</span><span class="pl-cce">\u</span>0300<span class="pl-cce">\u</span>0301<span class="pl-cce">\u</span>0303<span class="pl-kos">]</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span>
        <span class="pl-c1">map</span>: <span class="pl-kos">{</span>
          <span class="pl-s">'\u0069\u0307'</span>: <span class="pl-s">'\u0049'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u006A\u0307'</span>: <span class="pl-s">'\u004A'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u012F\u0307'</span>: <span class="pl-s">'\u012E'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0069\u0307\u0300'</span>: <span class="pl-s">'\u00CC'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0069\u0307\u0301'</span>: <span class="pl-s">'\u00CD'</span><span class="pl-kos">,</span>
          <span class="pl-s">'\u0069\u0307\u0303'</span>: <span class="pl-s">'\u0128'</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>

    <span class="pl-c">/**</span>
<span class="pl-c">     * Upper case a string.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * <span class="pl-k">@param</span>  {<span class="pl-smi">String</span>} str</span>
<span class="pl-c">     * <span class="pl-k">@return</span> {<span class="pl-smi">String</span>}</span>
<span class="pl-c">     */</span>
    <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-en">exports</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">str</span><span class="pl-kos">,</span> <span class="pl-s1">locale</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">var</span> <span class="pl-s1">lang</span> <span class="pl-c1">=</span> <span class="pl-c1">LANGUAGES</span><span class="pl-kos">[</span><span class="pl-s1">locale</span><span class="pl-kos">]</span>

      <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s1">str</span> <span class="pl-c1">==</span> <span class="pl-c1">null</span> ? <span class="pl-s">''</span> : <span class="pl-v">String</span><span class="pl-kos">(</span><span class="pl-s1">str</span><span class="pl-kos">)</span>

      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">lang</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">str</span> <span class="pl-c1">=</span> <span class="pl-s1">str</span><span class="pl-kos">.</span><span class="pl-en">replace</span><span class="pl-kos">(</span><span class="pl-s1">lang</span><span class="pl-kos">.</span><span class="pl-c1">regexp</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">m</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">lang</span><span class="pl-kos">.</span><span class="pl-c1">map</span><span class="pl-kos">[</span><span class="pl-s1">m</span><span class="pl-kos">]</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>
      <span class="pl-kos">}</span>

      <span class="pl-k">return</span> <span class="pl-s1">str</span><span class="pl-kos">.</span><span class="pl-en">toUpperCase</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>


<span class="pl-c">/***/</span> <span class="pl-kos">}</span>
<span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">We see here that the <code class="notranslate">upper-case</code> module has been duplicated in both of these initial chunk files.</p>
<h2 dir="auto">Feature request</h2>





<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto"><a href="https://webpack.js.org/configuration/resolve/#resolvemainfields" rel="nofollow">resolve.mainFields</a> should support <a href="https://nodejs.org/api/esm.html#esm_conditional_exports" rel="nofollow">Conditional Exports</a> in nodejs</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  &quot;exports&quot;: {
    &quot;.&quot;: {
      &quot;require&quot;: &quot;./dist/my-lib.cjs&quot;,
      &quot;import&quot;: &quot;./dist/my-lib.mjs&quot;
    }
  }"><pre class="notranslate">  <span class="pl-ent">"exports"</span>: {
    <span class="pl-ent">"."</span>: {
      <span class="pl-ent">"require"</span>: <span class="pl-s"><span class="pl-pds">"</span>./dist/my-lib.cjs<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"import"</span>: <span class="pl-s"><span class="pl-pds">"</span>./dist/my-lib.mjs<span class="pl-pds">"</span></span>
    }
  }</pre></div>