<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto"><code class="notranslate">@types/webpack</code> defines <code class="notranslate">SplitChunksOptions</code> as:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface SplitChunksOptions {
    /** Select chunks for determining shared modules (defaults to \&quot;async\&quot;, \&quot;initial\&quot; and \&quot;all\&quot; requires adding these chunks to the HTML) */
    chunks?: &quot;initial&quot; | &quot;async&quot; | &quot;all&quot; | ((chunk: compilation.Chunk) =&gt; boolean);
    /** Minimal size for the created chunk */
    minSize?: number;
    /** Minimum number of times a module has to be duplicated until it's considered for splitting */
    minChunks?: number;
    /** Maximum number of requests which are accepted for on-demand loading */
    maxAsyncRequests?: number;
    /** Maximum number of initial chunks which are accepted for an entry point */
    maxInitialRequests?: number;
    /** Give chunks created a name (chunks with equal name are merged) */
    name?: boolean | string | ((...args: any[]) =&gt; any);
    /** Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) */
    cacheGroups?: false | string | ((...args: any[]) =&gt; any) | RegExp | { [key: string]: CacheGroupsOptions };
}"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">SplitChunksOptions</span> <span class="pl-kos">{</span>
    <span class="pl-c">/** Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML) */</span>
    <span class="pl-c1">chunks</span>?: <span class="pl-s">"initial"</span> <span class="pl-c1">|</span> <span class="pl-s">"async"</span> <span class="pl-c1">|</span> <span class="pl-s">"all"</span> <span class="pl-c1">|</span> <span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">chunk</span>: <span class="pl-s1">compilation</span><span class="pl-kos">.</span><span class="pl-smi">Chunk</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">boolean</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-c">/** Minimal size for the created chunk */</span>
    <span class="pl-c1">minSize</span>?: <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-c">/** Minimum number of times a module has to be duplicated until it's considered for splitting */</span>
    <span class="pl-c1">minChunks</span>?: <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-c">/** Maximum number of requests which are accepted for on-demand loading */</span>
    <span class="pl-c1">maxAsyncRequests</span>?: <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-c">/** Maximum number of initial chunks which are accepted for an entry point */</span>
    <span class="pl-c1">maxInitialRequests</span>?: <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-c">/** Give chunks created a name (chunks with equal name are merged) */</span>
    <span class="pl-c1">name</span>?: <span class="pl-smi">boolean</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span> <span class="pl-c1">|</span> <span class="pl-kos">(</span><span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">any</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">any</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-c">/** Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) */</span>
    <span class="pl-c1">cacheGroups</span>?: <span class="pl-c1">false</span> <span class="pl-c1">|</span> <span class="pl-smi">string</span> <span class="pl-c1">|</span> <span class="pl-kos">(</span><span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">any</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">any</span><span class="pl-kos">)</span> <span class="pl-c1">|</span> <span class="pl-smi">RegExp</span> <span class="pl-c1">|</span> <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">key</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">CacheGroupsOptions</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">The <code class="notranslate">cacheGroups</code> property allows false, string, Function, RegExp and a map of CacheGroupOptions, however a special case is <code class="notranslate">cacheGroups: {default: false}}</code>, the <code class="notranslate">CacheGroupsOptions</code> interface does not allow <code class="notranslate">false</code> as value.</p>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  <code class="notranslate">@types/webpack</code> 4.4.13<br>
Node.js version: v10.11.0<br>
Operating System: macOS<br>
Additional tools:</p>
<p dir="auto">Source mapping was failing when bundling some JavaScript modules, and I have established that it was due to having multiple <code class="notranslate">//@ sourceMappingURL=...</code> directives in my bundle file. One came from a module that has been compiled from coffeescript. The module is a transient dependency via 2 other modules, so using the coffeescript loader to load the original coffeescript is not a reasonable option here.</p>
<p dir="auto">See also: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="33744328" data-permission-text="Title is private" data-url="https://github.com/myrne/performance-now/issues/2" data-hovercard-type="issue" data-hovercard-url="/myrne/performance-now/issues/2/hovercard" href="https://github.com/myrne/performance-now/issues/2">myrne/performance-now#2</a></p>
<p dir="auto">This is what I end up with at the end of my bundle:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    ...
    /*
    //@ sourceMappingURL=performance-now.map
    */

    /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(19)))

/***/ }
/******/ ])
/*
//@ sourceMappingURL=bundle.js.map
*/"><pre class="notranslate">    ...
    <span class="pl-c">/*</span>
<span class="pl-c">    //@ sourceMappingURL=performance-now.map</span>
<span class="pl-c">    */</span>

    <span class="pl-c">/* WEBPACK VAR INJECTION */</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">exports</span><span class="pl-kos">,</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-c1">19</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-c">/******/</span> <span class="pl-kos">]</span><span class="pl-kos">)</span>
<span class="pl-c">/*</span>
<span class="pl-c">//@ sourceMappingURL=bundle.js.map</span>
<span class="pl-c">*/</span></pre></div>
<p dir="auto">removing the <code class="notranslate">//@ sourceMappingURL=performance-now.map</code> line from the bundle causes the source maps to work in the browser (Chrome Version 34.0.1847.137 m).</p>
<p dir="auto">Firefox debugger seems to be able to handle the extra directive, but it also does not use it to map to the original .coffee file, so there doesn't seem to be any value in leaving the directive in place.</p>
<p dir="auto">Webpack could remove existing <code class="notranslate">sourceMappingURL</code> directives, and ideally bring the specified source maps in as a section in the bundle source map (See: <a href="https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US#heading=h.535es3xeprgt" rel="nofollow">https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US#heading=h.535es3xeprgt</a> )</p>
<h2 dir="auto">To reproduce:</h2>
<p dir="auto">create these files:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// package.json
{
  &quot;name&quot;: &quot;test&quot;,
  &quot;version&quot;: &quot;0.0.0&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;main&quot;: &quot;index.js&quot;,
  &quot;scripts&quot;: {
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
  },
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;dependencies&quot;: {
    &quot;performance-now&quot;: &quot;^0.1.3&quot;
  }
}"><pre class="notranslate"><span class="pl-ii">// package.json</span>
{
  <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.0.0<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"description"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"main"</span>: <span class="pl-s"><span class="pl-pds">"</span>index.js<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"scripts"</span>: {
    <span class="pl-ent">"test"</span>: <span class="pl-s"><span class="pl-pds">"</span>echo <span class="pl-cce">\"</span>Error: no test specified<span class="pl-cce">\"</span> &amp;&amp; exit 1<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"author"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"license"</span>: <span class="pl-s"><span class="pl-pds">"</span>ISC<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"dependencies"</span>: {
    <span class="pl-ent">"performance-now"</span>: <span class="pl-s"><span class="pl-pds">"</span>^0.1.3<span class="pl-pds">"</span></span>
  }
}</pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// webpack.config.js
module.exports = {
  entry: &quot;./index.js&quot;,
  output: {
    path: __dirname,
    filename: &quot;bundle.js&quot;
  },
  devtool: &quot;source-map&quot;
};"><pre class="notranslate"><span class="pl-c">// webpack.config.js</span>
<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-s">"./index.js"</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-s1">__dirname</span><span class="pl-kos">,</span>
    <span class="pl-c1">filename</span>: <span class="pl-s">"bundle.js"</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-c1">devtool</span>: <span class="pl-s">"source-map"</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;script src=&quot;./bundle.js&quot;&gt;&lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;"><pre class="notranslate"><span class="pl-c1">&lt;!DOCTYPE html<span class="pl-kos">&gt;</span></span>
<span class="pl-kos">&lt;</span><span class="pl-ent">html</span> <span class="pl-c1">lang</span>="<span class="pl-s">en</span>"<span class="pl-kos">&gt;</span>
  <span class="pl-kos">&lt;</span><span class="pl-ent">head</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">meta</span> <span class="pl-c1">charset</span>="<span class="pl-s">utf-8</span>"<span class="pl-kos">&gt;</span>
  <span class="pl-kos">&lt;/</span><span class="pl-ent">head</span><span class="pl-kos">&gt;</span>
  <span class="pl-kos">&lt;</span><span class="pl-ent">body</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">src</span>="<span class="pl-s">./bundle.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>
  <span class="pl-kos">&lt;/</span><span class="pl-ent">body</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span><span class="pl-ent">html</span><span class="pl-kos">&gt;</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var now = require('performance-now');
console.log('Logged from index.js:2');"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">now</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'performance-now'</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">'Logged from index.js:2'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">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">Open index.html in Chrome 29.</p>
<p dir="auto">Expected: console log shows "Logged from index.js:2" with link to line 2 of index.js<br>
Actual: console log shows "Logged from index.js:2" with link to line 50 of bundle.js</p>