<p dir="auto">I'd really like to be able to pass functions to loaders in my webpack config:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function jsLoader(source) {
  // do whatever...
}

module.exports = {
  ...,
  module: {
    loaders: [
      {test: /\.js$/, loader: jsLoader}
    ]
  },
  ...
};"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">jsLoader</span><span class="pl-kos">(</span><span class="pl-s1">source</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-c">// do whatever...</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-kos">{</span>
  ...<span class="pl-kos">,</span>
  <span class="pl-c1">module</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">loaders</span>: <span class="pl-kos">[</span>
      <span class="pl-kos">{</span><span class="pl-c1">test</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-cce">\.</span>js<span class="pl-cce">$</span><span class="pl-c1">/</span></span><span class="pl-kos">,</span> <span class="pl-c1">loader</span>: <span class="pl-s1">jsLoader</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></pre></div>
<p dir="auto">The reason is that I have some global configuration state in my webpack.config.js, example:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var STATIC_ROOT = 'path/to/static/root';"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-c1">STATIC_ROOT</span> <span class="pl-c1">=</span> <span class="pl-s">'path/to/static/root'</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">And my js_loader needs access to that static root for the transformation that it performs on the source code. My options are either to duplicate the configuration in each files, which is annoying to maintain and error-prone, or to throw all of the configuration variables into process.env, and from my js_loader, read them back from process.env, which just feels hacky.</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
I have a web app  which I bundle using the Webpack (using it only for bundling and generating chunks)</p>
<p dir="auto">Let's say after bundling I have the following output:<br>
<code class="notranslate">main.bundle.js</code>,<br>
<code class="notranslate">feature1.module.js</code>,<br>
<code class="notranslate">feature2.module.js</code></p>
<p dir="auto">On the html page (using a different tool) I include then:<br>
<code class="notranslate">main.bundle.js</code>,<br>
<code class="notranslate">feature1.module.js</code>,<br>
<code class="notranslate">feature2.module.js</code></p>
<p dir="auto">In this scenario it all works ok</p>
<p dir="auto">However as my system is runtime configurable I also have a situation where on the html page only the following is included:<br>
<code class="notranslate">main.bundle.js</code>,<br>
<code class="notranslate">feature1.module.js</code>,</p>
<p dir="auto">i.e. <code class="notranslate">feature2.module.js</code> is not included (because server app having this feature is not running).</p>
<p dir="auto">When I run the app now, Webpack during runtime initialization does not complete but quit silently without any message, to be exact:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" 	function checkDeferredModules() {
 		var result;
 		for(var i = 0; i &lt; deferredModules.length; i++) {
 			var deferredModule = deferredModules[i];
 			var fulfilled = true;
 			for(var j = 1; j &lt; deferredModule.length; j++) {
 				var depId = deferredModule[j];
				if(installedChunks[depId] !== 0) fulfilled = false;
 			}
 			if(fulfilled) {
 				deferredModules.splice(i--, 1);
				result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
 			}
 		}

 		return result;
 	}"><pre class="notranslate"> 	<span class="pl-k">function</span> <span class="pl-en">checkDeferredModules</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
 		<span class="pl-k">var</span> <span class="pl-s1">result</span><span class="pl-kos">;</span>
 		<span class="pl-k">for</span><span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">deferredModules</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
 			<span class="pl-k">var</span> <span class="pl-s1">deferredModule</span> <span class="pl-c1">=</span> <span class="pl-s1">deferredModules</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
 			<span class="pl-k">var</span> <span class="pl-s1">fulfilled</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
 			<span class="pl-k">for</span><span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-s1">j</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span><span class="pl-kos">;</span> <span class="pl-s1">j</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">deferredModule</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">j</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
 				<span class="pl-k">var</span> <span class="pl-s1">depId</span> <span class="pl-c1">=</span> <span class="pl-s1">deferredModule</span><span class="pl-kos">[</span><span class="pl-s1">j</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-s1">installedChunks</span><span class="pl-kos">[</span><span class="pl-s1">depId</span><span class="pl-kos">]</span> <span class="pl-c1">!==</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-s1">fulfilled</span> <span class="pl-c1">=</span> <span class="pl-c1">false</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-s1">fulfilled</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
 				<span class="pl-s1">deferredModules</span><span class="pl-kos">.</span><span class="pl-en">splice</span><span class="pl-kos">(</span><span class="pl-s1">i</span><span class="pl-c1">--</span><span class="pl-kos">,</span> <span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
				<span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-en">__webpack_require__</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-c1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">deferredModule</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-kos">;</span>
 			<span class="pl-kos">}</span>
 		<span class="pl-kos">}</span>

 		<span class="pl-k">return</span> <span class="pl-s1">result</span><span class="pl-kos">;</span>
 	<span class="pl-kos">}</span></pre></div>
<p dir="auto">The variable fullfilled is <code class="notranslate">false</code> and so the content of <code class="notranslate">main.module.js</code> is not loaded.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
When I "manually" set the variable <code class="notranslate">fulfilled</code> to <code class="notranslate">true</code> to tell Webpack something like: <em>ignore missing chunks because server app with this feature is not running and user will not have a access to features from <code class="notranslate">feature2.module.js</code></em></p>
<p dir="auto">The above scenario worked without problems with Webpack 3</p>
<p dir="auto">Is there any better way to say Webpack 4 to ignore missing chunks and continue with loading the app?</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  4.35.3<br>
Node.js version: 10.14.0</p>