<p dir="auto"><strong>Do you want to request a <em>feature</em> or report a <em>bug</em>?</strong></p>
<p dir="auto">Report a bug</p>
<p dir="auto"><strong>What is the current behavior?</strong><br>
My bundle gets compiled several times.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
I'm creating a webpack boilerplate for my personal projects, you can check it on this repo on the <code class="notranslate">cleanup</code> branch <a href="https://github.com/alejandronanez/webpack-boilerplate/tree/cleanup">https://github.com/alejandronanez/webpack-boilerplate/tree/cleanup</a></p>
<ol dir="auto">
<li><code class="notranslate">npm start</code></li>
<li>Add a few lines to <code class="notranslate">src/styles/app.scss</code> - a few empty new lines will do the trick</li>
<li>CTRL + C to stop the process</li>
<li><code class="notranslate">npm start</code> again</li>
<li>You should start seeing the bundle compiles on a loop for a while, and then it will stop</li>
</ol>
<p dir="auto">Here's a GIF with what is happening:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/464978/27987858-77b8a2d8-63da-11e7-8f5b-897f4f5de977.gif"><img src="https://user-images.githubusercontent.com/464978/27987858-77b8a2d8-63da-11e7-8f5b-897f4f5de977.gif" alt="webpack" data-animated-image="" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">The looping should not occur.</p>
<p dir="auto"><strong>If this is a feature request, what is motivation or use case for changing the behavior?</strong></p>
<p dir="auto"><strong>Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="node: 8.1.3 &amp;&amp; LTS
npm: 5.1.0
OSX: 10.12.5
webpack version: 3.1.0 &amp;&amp; 2.6.1"><pre class="notranslate"><code class="notranslate">node: 8.1.3 &amp;&amp; LTS
npm: 5.1.0
OSX: 10.12.5
webpack version: 3.1.0 &amp;&amp; 2.6.1
</code></pre></div>
<p dir="auto"><strong>Bug: I'm using webpack to build the server using target node, but the output claims requireEnsure as undefined!</strong></p>
<p dir="auto"><code class="notranslate">TypeError: __webpack_require__.e is not a function</code></p>
<p dir="auto">The function is related to webpack requireEnsure. It makes totally sense that we don't have requireEnsure (which appends html to the DOM) on the server, but why it's requiring it?</p>
<p dir="auto">The webpack configuration for the server is down to the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2] { devtool: 'source-map',
[2]   context: '/opt/app',
[2]   resolve:
[2]    { modules: [ 'node_modules' ],
[2]      extensions: [ '.json', '.js', '.jsx', '.css', '.scss' ] },
[2]   module:
[2]    { rules:
[2]       [ { test: /\.css$/,
[2]           include: /(flexboxgrid|normalize\.css)/,
[2]           use:
[2]            [ { loader: 'css-loader/locals',
[2]                options: { modules: true, importLoaders: 2, localIdentName: '[local]' } },
[2]              { loader: 'autoprefixer-loader',
[2]                options: { browsers: 'last 2 version' } } ] },
[2]         { test: /\.jsx?$/,
[2]           exclude: /node_modules/,
[2]           use:
[2]            [ { loader: 'babel-loader',
[2]                options:
[2]                 { plugins:
[2]                    [ 'transform-runtime',
[2]                      'add-module-exports',
[2]                      'transform-decorators-legacy',
[2]                      'transform-react-display-name',
[2]                      'transform-class-properties',
[2]                      [ 'react-intl',
[2]                        { messagesDir: './build/messages/', enforceDescriptions: true } ],
[2]                      [ 'root-import',
[2]                        [ { rootPathPrefix: '~', rootPathSuffix: 'src' },
[2]                          { rootPathPrefix: '@', rootPathSuffix: 'rest' },
[2]                          { rootPathPrefix: '#', rootPathSuffix: 'src/modules' } ] ],
[2]                      'syntax-dynamic-import' ],
[2]                   presets: [ 'react', 'es2015', 'stage-0' ],
[2]                   ignore: [ 'node_modules' ] } } ] },
[2]         { test: /\.less$/,
[2]           use:
[2]            [ { loader: 'css-loader/locals',
[2]                options:
[2]                 { modules: true,
[2]                   importLoaders: 2,
[2]                   sourceMap: true,
[2]                   localIdentName: '[local]___[hash:base64:5]' } },
[2]              { loader: 'autoprefixer-loader',
[2]                options: { browsers: 'last 2 version' } },
[2]              { loader: 'less-loader',
[2]                options: { outputStyle: 'expanded', sourceMap: true } } ] },
[2]         { test: /\.scss$/,
[2]           use:
[2]            [ { loader: 'css-loader/locals',
[2]                options:
[2]                 { modules: true,
[2]                   importLoaders: 2,
[2]                   sourceMap: true,
[2]                   localIdentName: '[local]___[hash:base64:5]' } },
[2]              { loader: 'autoprefixer-loader',
[2]                options: { browsers: 'last 2 version' } },
[2]              { loader: 'sass-loader',
[2]                options: { outputStyle: 'expanded', sourceMap: true } } ] },
[2]         { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/font-woff',
[2]                   emitFile: false } } ] },
[2]         { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/font-woff',
[2]                   emitFile: false } } ] },
[2]         { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/octet-stream',
[2]                   emitFile: false } } ] },
[2]         { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
[2]           use: [ { loader: 'file-loader', options: { emitFile: false } } ] },
[2]         { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/octet-stream',
[2]                   emitFile: false } } ] },
[2]         { test: /\.(jpg|png|jpeg|gif|svg)$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options: { limit: 10240, emitFile: false } } ] } ] },
[2]   plugins:
[2]    [ DefinePlugin {
[2]        definitions:
[2]         { __CLIENT__: false,
[2]           __SERVER__: true,
[2]           __DEVELOPMENT__: true,
[2]           __DEVTOOLS__: true } },
[2]      LimitChunkCountPlugin { options: { maxChunks: 1 } } ],
[2]   name: 'server',
[2]   output:
[2]    { path: '/opt/app/build/server',
[2]      libraryTarget: 'commonjs2',
[2]      filename: '[name].js',
[2]      chunkFilename: '[name].js',
[2]      pathinfo: true },
[2]   entry: { server: [ './src/server.js' ] },
[2]   target: 'node',
[2]   node: { __dirname: false, __filename: false },
[2]   externals: [ [Function] ] }"><pre class="notranslate"><code class="notranslate">[2] { devtool: 'source-map',
[2]   context: '/opt/app',
[2]   resolve:
[2]    { modules: [ 'node_modules' ],
[2]      extensions: [ '.json', '.js', '.jsx', '.css', '.scss' ] },
[2]   module:
[2]    { rules:
[2]       [ { test: /\.css$/,
[2]           include: /(flexboxgrid|normalize\.css)/,
[2]           use:
[2]            [ { loader: 'css-loader/locals',
[2]                options: { modules: true, importLoaders: 2, localIdentName: '[local]' } },
[2]              { loader: 'autoprefixer-loader',
[2]                options: { browsers: 'last 2 version' } } ] },
[2]         { test: /\.jsx?$/,
[2]           exclude: /node_modules/,
[2]           use:
[2]            [ { loader: 'babel-loader',
[2]                options:
[2]                 { plugins:
[2]                    [ 'transform-runtime',
[2]                      'add-module-exports',
[2]                      'transform-decorators-legacy',
[2]                      'transform-react-display-name',
[2]                      'transform-class-properties',
[2]                      [ 'react-intl',
[2]                        { messagesDir: './build/messages/', enforceDescriptions: true } ],
[2]                      [ 'root-import',
[2]                        [ { rootPathPrefix: '~', rootPathSuffix: 'src' },
[2]                          { rootPathPrefix: '@', rootPathSuffix: 'rest' },
[2]                          { rootPathPrefix: '#', rootPathSuffix: 'src/modules' } ] ],
[2]                      'syntax-dynamic-import' ],
[2]                   presets: [ 'react', 'es2015', 'stage-0' ],
[2]                   ignore: [ 'node_modules' ] } } ] },
[2]         { test: /\.less$/,
[2]           use:
[2]            [ { loader: 'css-loader/locals',
[2]                options:
[2]                 { modules: true,
[2]                   importLoaders: 2,
[2]                   sourceMap: true,
[2]                   localIdentName: '[local]___[hash:base64:5]' } },
[2]              { loader: 'autoprefixer-loader',
[2]                options: { browsers: 'last 2 version' } },
[2]              { loader: 'less-loader',
[2]                options: { outputStyle: 'expanded', sourceMap: true } } ] },
[2]         { test: /\.scss$/,
[2]           use:
[2]            [ { loader: 'css-loader/locals',
[2]                options:
[2]                 { modules: true,
[2]                   importLoaders: 2,
[2]                   sourceMap: true,
[2]                   localIdentName: '[local]___[hash:base64:5]' } },
[2]              { loader: 'autoprefixer-loader',
[2]                options: { browsers: 'last 2 version' } },
[2]              { loader: 'sass-loader',
[2]                options: { outputStyle: 'expanded', sourceMap: true } } ] },
[2]         { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/font-woff',
[2]                   emitFile: false } } ] },
[2]         { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/font-woff',
[2]                   emitFile: false } } ] },
[2]         { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/octet-stream',
[2]                   emitFile: false } } ] },
[2]         { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
[2]           use: [ { loader: 'file-loader', options: { emitFile: false } } ] },
[2]         { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options:
[2]                 { limit: 10000,
[2]                   mimetype: 'application/octet-stream',
[2]                   emitFile: false } } ] },
[2]         { test: /\.(jpg|png|jpeg|gif|svg)$/,
[2]           use:
[2]            [ { loader: 'url-loader',
[2]                options: { limit: 10240, emitFile: false } } ] } ] },
[2]   plugins:
[2]    [ DefinePlugin {
[2]        definitions:
[2]         { __CLIENT__: false,
[2]           __SERVER__: true,
[2]           __DEVELOPMENT__: true,
[2]           __DEVTOOLS__: true } },
[2]      LimitChunkCountPlugin { options: { maxChunks: 1 } } ],
[2]   name: 'server',
[2]   output:
[2]    { path: '/opt/app/build/server',
[2]      libraryTarget: 'commonjs2',
[2]      filename: '[name].js',
[2]      chunkFilename: '[name].js',
[2]      pathinfo: true },
[2]   entry: { server: [ './src/server.js' ] },
[2]   target: 'node',
[2]   node: { __dirname: false, __filename: false },
[2]   externals: [ [Function] ] }
</code></pre></div>
<p dir="auto">The undefined function is only mentioned once in the outputted code, but the <code class="notranslate">webpackAsyncContext</code> apparently is executed for every module.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function webpackAsyncContext(req) {
        var ids = map[req];
        if(!ids)
                return Promise.reject(new Error(&quot;Cannot find module '&quot; + req + &quot;'.&quot;));
        return __webpack_require__.e(ids[1]).then(function() {
                return __webpack_require__(ids[0]);
        });
};
"><pre class="notranslate"><code class="notranslate">function webpackAsyncContext(req) {
        var ids = map[req];
        if(!ids)
                return Promise.reject(new Error("Cannot find module '" + req + "'."));
        return __webpack_require__.e(ids[1]).then(function() {
                return __webpack_require__(ids[0]);
        });
};

</code></pre></div>
<p dir="auto"><strong>The expected behavior</strong></p>
<p dir="auto">I believe that the build with target node shouldn't be trying to use requireEnsure, or maybe it is missing the <code class="notranslate">libraryTarget</code> for <code class="notranslate">commonjs2</code>. The problem is that the webpack outputted file is trying to execute <code class="notranslate">__webpack_require__.e</code> but it doesn't defined the method anywhere on the output, so it shouldn't be executing it.</p>
<p dir="auto"><strong>My configuration is</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="node v.7.7.2
npm 4.1.2
webpack 2.2.0
babel-core 6.24.1
babel-loader 7.0.0"><pre class="notranslate"><code class="notranslate">node v.7.7.2
npm 4.1.2
webpack 2.2.0
babel-core 6.24.1
babel-loader 7.0.0
</code></pre></div>