<h1 dir="auto">Bug report</h1>
<h2 dir="auto">Describe the bug</h2>
<p dir="auto">Dynamic routing to page with ant.design Table component doesn't work.<br>
Bug only appears on build. On dev run it works properly.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">I have two pages: Main and Sub.<br>
Sub page contains component which contains Table component.<br>
When I go from Main page to Sub page via Link (dynamic routing) then nothing happens and I am not redirected to Sub page. When I type Sub page url manually to browser bar then Sup page loads.</p>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">I should be redirected to Sup page via Link (dynamic routing).</p>
<h2 dir="auto">Additional context</h2>
<p dir="auto">I am using latest versions for antd, nextjs, typescript.</p>
<p dir="auto">Firstly I was using Table component in Sub page directly. (Sub has Table)<br>
Importing via below code didn't work and caused above error:<br>
<code class="notranslate">import { Table } from 'antd'</code><br>
I have fixed it with importing Table directly<br>
<code class="notranslate">import Table from 'antd/lib/table'</code></p>
<p dir="auto">Later on I had to move Table component to sub component. And both import doesn't work now.  (SomeComponent has Table, Sub has SomeComponent)</p>
<p dir="auto">next.config.js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/* eslint-disable */
const withLess = require('@zeit/next-less')
const lessToJS = require('less-vars-to-js')
const fs = require('fs')
const path = require('path')

// Where your antd-custom.less file lives
const themeVariables = lessToJS(
    fs.readFileSync(path.resolve(__dirname, './assets/theme.less'), 'utf8')
)

module.exports = withLess({
    exportTrailingSlash: false,
    lessLoaderOptions: {
        javascriptEnabled: true,
        modifyVars: themeVariables, // make your antd custom effective
    },
    webpack: (config, { isServer }) =&gt; {
        if (isServer) {
            const antStyles = /antd\/.*?\/style.*?/
            const origExternals = [...config.externals]
            config.externals = [
                (context, request, callback) =&gt; {
                    if (request.match(antStyles)) return callback()
                    if (typeof origExternals[0] === 'function') {
                        origExternals[0](context, request, callback)
                    } else {
                        callback()
                    }
                },
                ...(typeof origExternals[0] === 'function'
                    ? []
                    : origExternals),
            ]
            config.externals.exclude = /node_modules\/(?!(os)\/).*/

            config.module.rules.unshift({
                test: antStyles,
                use: 'null-loader',
            })
        }
        return config
    },
})"><pre class="notranslate"><span class="pl-c">/* eslint-disable */</span>
<span class="pl-k">const</span> <span class="pl-s1">withLess</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'@zeit/next-less'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">lessToJS</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'less-vars-to-js'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">fs</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'fs'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">path</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'path'</span><span class="pl-kos">)</span>

<span class="pl-c">// Where your antd-custom.less file lives</span>
<span class="pl-k">const</span> <span class="pl-s1">themeVariables</span> <span class="pl-c1">=</span> <span class="pl-s1">lessToJS</span><span class="pl-kos">(</span>
    <span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">readFileSync</span><span class="pl-kos">(</span><span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">__dirname</span><span class="pl-kos">,</span> <span class="pl-s">'./assets/theme.less'</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s">'utf8'</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-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-s1">withLess</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
    <span class="pl-c1">exportTrailingSlash</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-c1">lessLoaderOptions</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">javascriptEnabled</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
        <span class="pl-c1">modifyVars</span>: <span class="pl-s1">themeVariables</span><span class="pl-kos">,</span> <span class="pl-c">// make your antd custom effective</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-en">webpack</span>: <span class="pl-kos">(</span><span class="pl-s1">config</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> isServer <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">isServer</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">const</span> <span class="pl-s1">antStyles</span> <span class="pl-c1">=</span> <span class="pl-pds"><span class="pl-c1">/</span>antd<span class="pl-cce">\/</span>.<span class="pl-c1">*</span>?<span class="pl-cce">\/</span>style.<span class="pl-c1">*</span>?<span class="pl-c1">/</span></span>
            <span class="pl-k">const</span> <span class="pl-s1">origExternals</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span>...<span class="pl-s1">config</span><span class="pl-kos">.</span><span class="pl-c1">externals</span><span class="pl-kos">]</span>
            <span class="pl-s1">config</span><span class="pl-kos">.</span><span class="pl-c1">externals</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span>
                <span class="pl-kos">(</span><span class="pl-s1">context</span><span class="pl-kos">,</span> <span class="pl-s1">request</span><span class="pl-kos">,</span> <span class="pl-s1">callback</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
                    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">request</span><span class="pl-kos">.</span><span class="pl-en">match</span><span class="pl-kos">(</span><span class="pl-s1">antStyles</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-k">return</span> <span class="pl-s1">callback</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
                    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-k">typeof</span> <span class="pl-s1">origExternals</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-s">'function'</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                        <span class="pl-s1">origExternals</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-s1">context</span><span class="pl-kos">,</span> <span class="pl-s1">request</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-k">else</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-kos">}</span>
                <span class="pl-kos">}</span><span class="pl-kos">,</span>
                ...<span class="pl-kos">(</span><span class="pl-k">typeof</span> <span class="pl-s1">origExternals</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-s">'function'</span>
                    ? <span class="pl-kos">[</span><span class="pl-kos">]</span>
                    : <span class="pl-s1">origExternals</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
            <span class="pl-kos">]</span>
            <span class="pl-s1">config</span><span class="pl-kos">.</span><span class="pl-c1">externals</span><span class="pl-kos">.</span><span class="pl-c1">exclude</span> <span class="pl-c1">=</span> <span class="pl-pds"><span class="pl-c1">/</span>node_modules<span class="pl-cce">\/</span><span class="pl-kos">(?</span><span class="pl-c1">!</span><span class="pl-kos">(</span>os<span class="pl-kos">)</span><span class="pl-cce">\/</span><span class="pl-kos">)</span>.<span class="pl-c1">*</span><span class="pl-c1">/</span></span>

            <span class="pl-s1">config</span><span class="pl-kos">.</span><span class="pl-c1">module</span><span class="pl-kos">.</span><span class="pl-c1">rules</span><span class="pl-kos">.</span><span class="pl-en">unshift</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
                <span class="pl-c1">test</span>: <span class="pl-s1">antStyles</span><span class="pl-kos">,</span>
                <span class="pl-c1">use</span>: <span class="pl-s">'null-loader'</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">config</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">.babelrc</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;presets&quot;: [&quot;next/babel&quot;],
    &quot;plugins&quot;: [
        [
            &quot;import&quot;,
            {
                &quot;libraryName&quot;: &quot;antd&quot;,
                &quot;style&quot;: true
            }
        ]
    ]
}"><pre class="notranslate">{
    <span class="pl-ent">"presets"</span>: [<span class="pl-s"><span class="pl-pds">"</span>next/babel<span class="pl-pds">"</span></span>],
    <span class="pl-ent">"plugins"</span>: [
        [
            <span class="pl-s"><span class="pl-pds">"</span>import<span class="pl-pds">"</span></span>,
            {
                <span class="pl-ent">"libraryName"</span>: <span class="pl-s"><span class="pl-pds">"</span>antd<span class="pl-pds">"</span></span>,
                <span class="pl-ent">"style"</span>: <span class="pl-c1">true</span>
            }
        ]
    ]
}</pre></div>
<h1 dir="auto">Examples bug report</h1>
<h2 dir="auto">Example name</h2>
<p dir="auto">with-ant-design-less<br>
<a href="https://github.com/zeit/next.js/tree/canary/examples/with-ant-design-less">https://github.com/zeit/next.js/tree/canary/examples/with-ant-design-less</a></p>
<h2 dir="auto">Describe the bug</h2>
<p dir="auto">When I click on a Link to a page that uses any antd component, it doesn't work and when I click on a Link to a page that doesn't use any antd component, it works.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">I create a codesandbox to reproduce te bug <a href="https://codesandbox.io/s/nextjs-ant-design-8t41c" rel="nofollow">https://codesandbox.io/s/nextjs-ant-design-8t41c</a></p>
<ul dir="auto">
<li>Click on "Go to page with antd" doesn't work</li>
<li>Click on "Go to page without antd"  works</li>
</ul>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">The Link redirect to page that uses antd</p>
<h2 dir="auto">System information</h2>
<p dir="auto">Dependencies:<br>
"@zeit/next-less": "1.0.1",<br>
"antd": "3.25.1",<br>
"babel-plugin-import": "1.12.2",<br>
"less": "3.10.3",<br>
"less-vars-to-js": "1.3.0",<br>
"next": "latest",<br>
"null-loader": "3.0.0",<br>
"react": "^16.7.0",<br>
"react-dom": "^16.7.0"</p>