<h1 dir="auto">Bug report</h1>
<h2 dir="auto">Describe the bug</h2>
<p dir="auto">When using Webpack's magic comment (<code class="notranslate">/* webpackChunkName: "balabala" */</code>) to specify several modules bundling into one chunck, the output html contains duplicated <code class="notranslate">&lt;link rel='preload'&gt;</code> and <code class="notranslate">&lt;script&gt;</code> for the same chunck</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">a simple respository to reproduce the bug:</p>
<p dir="auto"><a href="https://github.com/xboy2012/nextjs-duplicate-dynamic-reproduce">https://github.com/xboy2012/nextjs-duplicate-dynamic-reproduce</a></p>
<p dir="auto">In the respository I defined two modules, <code class="notranslate">Module1</code> and <code class="notranslate">Module2</code>, using <code class="notranslate">/* webpackChunkName: "allModules" */</code> to make them bundling into chunck <code class="notranslate">allModules</code>.</p>
<p dir="auto">Just execute <code class="notranslate">npm run dev</code>, open <code class="notranslate">http://localhost:3000/</code> in your browser.</p>
<p dir="auto">Inspect the result HTML, then you'll see duplicated <code class="notranslate">&lt;link rel='preload'&gt;</code> and <code class="notranslate">&lt;script&gt;</code> such as follows:</p>
<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&gt;
    &lt;head&gt;
        &lt;meta charSet=&quot;utf-8&quot; class=&quot;next-head&quot;/&gt;
        &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,minimum-scale=1,initial-scale=1&quot; class=&quot;next-head&quot;/&gt;
        &lt;link rel=&quot;preload&quot; href=&quot;/_next/static/development/pages/index.js?ts=1558408463129&quot; as=&quot;script&quot;/&gt;
        &lt;link rel=&quot;preload&quot; href=&quot;/_next/static/development/pages/_app.js?ts=1558408463129&quot; as=&quot;script&quot;/&gt;
        &lt;link rel=&quot;preload&quot; href=&quot;/_next/static/chunks/allModules.js?ts=1558408463129&quot; as=&quot;script&quot;/&gt;
        &lt;link rel=&quot;preload&quot; href=&quot;/_next/static/chunks/allModules.js?ts=1558408463129&quot; as=&quot;script&quot;/&gt;
        &lt;link rel=&quot;preload&quot; href=&quot;/_next/static/runtime/webpack.js?ts=1558408463129&quot; as=&quot;script&quot;/&gt;
        &lt;link rel=&quot;preload&quot; href=&quot;/_next/static/runtime/main.js?ts=1558408463129&quot; as=&quot;script&quot;/&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id=&quot;__next&quot;&gt;
            &lt;div&gt;
                &lt;div&gt;This is module1&lt;/div&gt;
                &lt;div&gt;This is module2&lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;script src=&quot;/_next/static/development/dll/dll_2011977376de5c4d4cfb.js?ts=1558408463129&quot;&gt;&lt;/script&gt;
        &lt;script id=&quot;__NEXT_DATA__&quot; type=&quot;application/json&quot;&gt;
            {&quot;dataManager&quot;:&quot;[]&quot;,&quot;props&quot;:{&quot;pageProps&quot;:{}},&quot;page&quot;:&quot;/&quot;,&quot;query&quot;:{},&quot;buildId&quot;:&quot;development&quot;,&quot;dynamicBuildId&quot;:false,&quot;dynamicIds&quot;:[&quot;./components/Module1.js&quot;,&quot;./components/Module1.js&quot;]}
        &lt;/script&gt;
        &lt;script async=&quot;&quot; id=&quot;__NEXT_PAGE__/&quot; src=&quot;/_next/static/development/pages/index.js?ts=1558408463129&quot;&gt;&lt;/script&gt;
        &lt;script async=&quot;&quot; id=&quot;__NEXT_PAGE__/_app&quot; src=&quot;/_next/static/development/pages/_app.js?ts=1558408463129&quot;&gt;&lt;/script&gt;
        &lt;script async=&quot;&quot; src=&quot;/_next/static/chunks/allModules.js?ts=1558408463129&quot;&gt;&lt;/script&gt;
        &lt;script async=&quot;&quot; src=&quot;/_next/static/chunks/allModules.js?ts=1558408463129&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;/_next/static/runtime/webpack.js?ts=1558408463129&quot; async=&quot;&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;/_next/static/runtime/main.js?ts=1558408463129&quot; async=&quot;&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-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-c1">class</span>="<span class="pl-s">next-head</span>"/&gt;
        <span class="pl-kos">&lt;</span><span class="pl-ent">meta</span> <span class="pl-c1">name</span>="<span class="pl-s">viewport</span>" <span class="pl-c1">content</span>="<span class="pl-s">width=device-width,minimum-scale=1,initial-scale=1</span>" <span class="pl-c1">class</span>="<span class="pl-s">next-head</span>"/&gt;
        <span class="pl-kos">&lt;</span><span class="pl-ent">link</span> <span class="pl-c1">rel</span>="<span class="pl-s">preload</span>" <span class="pl-c1">href</span>="<span class="pl-s">/_next/static/development/pages/index.js?ts=1558408463129</span>" <span class="pl-c1">as</span>="<span class="pl-s">script</span>"/&gt;
        <span class="pl-kos">&lt;</span><span class="pl-ent">link</span> <span class="pl-c1">rel</span>="<span class="pl-s">preload</span>" <span class="pl-c1">href</span>="<span class="pl-s">/_next/static/development/pages/_app.js?ts=1558408463129</span>" <span class="pl-c1">as</span>="<span class="pl-s">script</span>"/&gt;
        <span class="pl-kos">&lt;</span><span class="pl-ent">link</span> <span class="pl-c1">rel</span>="<span class="pl-s">preload</span>" <span class="pl-c1">href</span>="<span class="pl-s">/_next/static/chunks/allModules.js?ts=1558408463129</span>" <span class="pl-c1">as</span>="<span class="pl-s">script</span>"/&gt;
        <span class="pl-kos">&lt;</span><span class="pl-ent">link</span> <span class="pl-c1">rel</span>="<span class="pl-s">preload</span>" <span class="pl-c1">href</span>="<span class="pl-s">/_next/static/chunks/allModules.js?ts=1558408463129</span>" <span class="pl-c1">as</span>="<span class="pl-s">script</span>"/&gt;
        <span class="pl-kos">&lt;</span><span class="pl-ent">link</span> <span class="pl-c1">rel</span>="<span class="pl-s">preload</span>" <span class="pl-c1">href</span>="<span class="pl-s">/_next/static/runtime/webpack.js?ts=1558408463129</span>" <span class="pl-c1">as</span>="<span class="pl-s">script</span>"/&gt;
        <span class="pl-kos">&lt;</span><span class="pl-ent">link</span> <span class="pl-c1">rel</span>="<span class="pl-s">preload</span>" <span class="pl-c1">href</span>="<span class="pl-s">/_next/static/runtime/main.js?ts=1558408463129</span>" <span class="pl-c1">as</span>="<span class="pl-s">script</span>"/&gt;
    <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">div</span> <span class="pl-c1">id</span>="<span class="pl-s">__next</span>"<span class="pl-kos">&gt;</span>
            <span class="pl-kos">&lt;</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>
                <span class="pl-kos">&lt;</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>This is module1<span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>
                <span class="pl-kos">&lt;</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>This is module2<span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>
            <span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>
        <span class="pl-kos">&lt;/</span><span class="pl-ent">div</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">/_next/static/development/dll/dll_2011977376de5c4d4cfb.js?ts=1558408463129</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">script</span> <span class="pl-c1">id</span>="<span class="pl-s">__NEXT_DATA__</span>" <span class="pl-c1">type</span>="<span class="pl-s">application/json</span>"<span class="pl-kos">&gt;</span>
            <span class="pl-kos">{</span><span class="pl-s">"dataManager"</span>:<span class="pl-s">"[]"</span><span class="pl-kos">,</span><span class="pl-s">"props"</span>:<span class="pl-kos">{</span><span class="pl-s">"pageProps"</span>:<span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">}</span><span class="pl-kos">,</span><span class="pl-s">"page"</span>:<span class="pl-s">"/"</span><span class="pl-kos">,</span><span class="pl-s">"query"</span>:<span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span><span class="pl-s">"buildId"</span>:<span class="pl-s">"development"</span><span class="pl-kos">,</span><span class="pl-s">"dynamicBuildId"</span>:<span class="pl-c1">false</span><span class="pl-kos">,</span><span class="pl-s">"dynamicIds"</span>:<span class="pl-kos">[</span><span class="pl-s">"./components/Module1.js"</span><span class="pl-kos">,</span><span class="pl-s">"./components/Module1.js"</span><span class="pl-kos">]</span><span class="pl-kos">}</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">script</span> <span class="pl-c1">async</span>="" <span class="pl-c1">id</span>="<span class="pl-s">__NEXT_PAGE__/</span>" <span class="pl-c1">src</span>="<span class="pl-s">/_next/static/development/pages/index.js?ts=1558408463129</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">script</span> <span class="pl-c1">async</span>="" <span class="pl-c1">id</span>="<span class="pl-s">__NEXT_PAGE__/_app</span>" <span class="pl-c1">src</span>="<span class="pl-s">/_next/static/development/pages/_app.js?ts=1558408463129</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">script</span> <span class="pl-c1">async</span>="" <span class="pl-c1">src</span>="<span class="pl-s">/_next/static/chunks/allModules.js?ts=1558408463129</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">script</span> <span class="pl-c1">async</span>="" <span class="pl-c1">src</span>="<span class="pl-s">/_next/static/chunks/allModules.js?ts=1558408463129</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">script</span> <span class="pl-c1">src</span>="<span class="pl-s">/_next/static/runtime/webpack.js?ts=1558408463129</span>" <span class="pl-c1">async</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">script</span> <span class="pl-c1">src</span>="<span class="pl-s">/_next/static/runtime/main.js?ts=1558408463129</span>" <span class="pl-c1">async</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>
<p dir="auto">Obviously, <code class="notranslate">allModules.js</code> is preloaded and loaded twice.</p>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">There should be no duplicated <code class="notranslate">&lt;link rel='preload'&gt;</code> and <code class="notranslate">&lt;script&gt;</code> for the same file.</p>
<h2 dir="auto">Screenshots</h2>
<p dir="auto">See the above description</p>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>OS: macOS</li>
<li>Browser Chrome</li>
<li>Version of Next.js:</li>
</ul>
<p dir="auto">I wrote the repository to reproduce the bug using Next 8.x</p>
<p dir="auto">In my company project I face the same bug using Next 7.x</p>
<p dir="auto">So it's likely all version have the bug</p>
<h2 dir="auto">Additional context</h2>
<p dir="auto">Not yet.</p>
<p dir="auto">It seems that the PropTypes for the <code class="notranslate">href</code> prop of Link component doesn't expect an object instead of a URL string.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;Link href={{ pathname: '/', query: { id: 1 } }}&gt;&lt;a&gt;Test&lt;/a&gt;&lt;/Link&gt;"><pre class="notranslate"><span class="pl-c1">&lt;</span><span class="pl-ent">Link</span> <span class="pl-c1">href</span><span class="pl-c1">=</span><span class="pl-kos">{</span><span class="pl-kos">{</span> <span class="pl-c1">pathname</span>: <span class="pl-s">'/'</span><span class="pl-kos">,</span> <span class="pl-c1">query</span>: <span class="pl-kos">{</span> <span class="pl-c1">id</span>: <span class="pl-c1">1</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-c1">&lt;</span><span class="pl-ent">a</span><span class="pl-c1">&gt;</span>Test<span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-ent">a</span><span class="pl-c1">&gt;</span><span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-ent">Link</span><span class="pl-c1">&gt;</span></pre></div>
<p dir="auto">This works fine, but a warning is raised:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Warning: Failed prop type: Invalid prop `href` of type `object` supplied to `Link`, expected `string`."><pre class="notranslate"><code class="notranslate">Warning: Failed prop type: Invalid prop `href` of type `object` supplied to `Link`, expected `string`.
</code></pre></div>
<h2 dir="auto">Your Environment</h2>
<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>3.0.1-beta.17</td>
</tr>
<tr>
<td>node</td>
<td>8.1.4</td>
</tr>
<tr>
<td>OS</td>
<td>Arch Linux</td>
</tr>
<tr>
<td>browser</td>
<td>Google Chrome (latest stable)</td>
</tr>
</tbody>
</table>