<p dir="auto">Thanks for next.js , I think it's awesome and has enabled me to progress a universal website much quicker than I could of done trying to build it out from scratch!</p>
<p dir="auto">I have added an entry point in my config for a component that ends up in the /static folder, this is a script that I am loading onto a script tag on componentDidMount and accessed via a Web Worker:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const { ANALYZE } = process.env
const path = require('path');

module.exports = {
  webpack: function (config) {
    console.log(config);
    if (ANALYZE) {
      config.plugins.push(new BundleAnalyzerPlugin({
        analyzerMode: 'server',
        analyzerPort: 8888,
        openAnalyzer: true
      }))
    }

    return Object.assign({}, config, { entry: function() {
      return config.entry().then((entry) =&gt; {
        return Object.assign({}, entry, { '../static/components/canvasAnim.js': './components/CanvasAnim'})
      })
    }})

    return config;

  }
}"><pre class="notranslate"><code class="notranslate">const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const { ANALYZE } = process.env
const path = require('path');

module.exports = {
  webpack: function (config) {
    console.log(config);
    if (ANALYZE) {
      config.plugins.push(new BundleAnalyzerPlugin({
        analyzerMode: 'server',
        analyzerPort: 8888,
        openAnalyzer: true
      }))
    }

    return Object.assign({}, config, { entry: function() {
      return config.entry().then((entry) =&gt; {
        return Object.assign({}, entry, { '../static/components/canvasAnim.js': './components/CanvasAnim'})
      })
    }})

    return config;

  }
}
</code></pre></div>
<p dir="auto">My script is working in dev, but when I build it does not seem to get touched. I was expecting this to end up all minified. So when I run the code in prod, React complains with: Error: Minified React error <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="185863194" data-permission-text="Title is private" data-url="https://github.com/vercel/next.js/issues/130" data-hovercard-type="issue" data-hovercard-url="/vercel/next.js/issues/130/hovercard" href="https://github.com/vercel/next.js/issues/130">#130</a>;</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>

<p dir="auto">I don't think I am describing a bug here, probably something I am missing around the way next.js config works!</p>

<h2 dir="auto">Current Behavior</h2>

<p dir="auto">During build the entry does not seem to be touched.</p>

<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<ol dir="auto">
<li>Add an entry point that maps to static and then build</li>
</ol>
<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>latest</td>
</tr>
<tr>
<td>node</td>
<td>8.6.0</td>
</tr>
<tr>
<td>OS</td>
<td>macOs 10.12.6</td>
</tr>
<tr>
<td>browser</td>
<td>chrome 61</td>
</tr>
<tr>
<td>etc</td>
<td></td>
</tr>
</tbody>
</table>
<p dir="auto">The client bundle always includes <code class="notranslate">node-libs-browser</code>, even if it is unnecessary. Removing it would reduce a hello world Next.js app page load by 19.62 KB (2.02 KB min gzip):</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1754873/38538707-5aa8a382-3cd8-11e8-8993-995a1f01eca5.png"><img width="658" alt="screen shot 2018-04-10 at 3 58 45 pm" src="https://user-images.githubusercontent.com/1754873/38538707-5aa8a382-3cd8-11e8-8993-995a1f01eca5.png" style="max-width: 100%;"></a></p>
<p dir="auto">This package is necessary if using <code class="notranslate">process.browser</code>, but this is currently only <a href="https://github.com/zeit/next.js/blob/6.0.0-canary.3/examples/with-apollo/lib/initApollo.js#L9">used in examples</a> and can be replaced easily with <code class="notranslate">typeof window !== 'undefined'</code>.</p>
<p dir="auto">I don't know the best way to remove it, as it is included by Webpack. Here are some related links:</p>
<ul dir="auto">
<li><a href="https://medium.com/walmartlabs/webpack-optimization-a-case-study-92b130334b6c" rel="nofollow">https://medium.com/walmartlabs/webpack-optimization-a-case-study-92b130334b6c</a></li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="232723424" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/4976" data-hovercard-type="issue" data-hovercard-url="/webpack/webpack/issues/4976/hovercard" href="https://github.com/webpack/webpack/issues/4976">webpack/webpack#4976</a></li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="233349207" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/4995" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/4995/hovercard" href="https://github.com/webpack/webpack/pull/4995">webpack/webpack#4995</a></li>
</ul>



<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?q=is%3Aissue">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<p dir="auto">The client bundle does not include <code class="notranslate">node-libs-browser</code> if it's unnecessary.</p>
<h2 dir="auto">Current Behavior</h2>
<p dir="auto">The client bundle includes <code class="notranslate">node-libs-browser</code> even if it's unnecessary.</p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>
<p dir="auto">Follow the basic Next.js setup instructions.</p>
<p dir="auto">Follow the basic <code class="notranslate">@zeit/next-bundle-analyzer</code> setup  instructions to see the problem visually.</p>
<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>v5.1.0 (or v6.0.0-canary.3)</td>
</tr>
<tr>
<td>node</td>
<td>v9.10.0</td>
</tr>
</tbody>
</table>