<h1 dir="auto">Bug report</h1>
<p dir="auto">As written on the title I have the issue of having <code class="notranslate">__webpack_exports__</code> that is undefined when loading (later) a second entry point.</p>
<p dir="auto">I'm using the latest lib versions <code class="notranslate">webpack@5.35.0</code> and <code class="notranslate">webpack-dev-server@3.11.2</code> on node <code class="notranslate">v15.11.0</code> on Linux.</p>
<p dir="auto">I have a very simple config:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    entry: {
      index: {
        import: [paths.appIndexJs, ...((isEnvDevelopment &amp;&amp; !shouldUseReactRefresh &amp;&amp; [webpackDevClientEntry]) || [])],
        runtime: 'runtime'
      },
      app: {
        import: paths.appAppTsx,
        dependOn: 'index'
      }
    },
    output: {
      filename: '/js/[name].js',
      globalObject: 'window',
      library: {
        // name: 'index',
        type: 'window'
      },
      iife: true
    }
    [...]"><pre class="notranslate">    <span class="pl-s1">entry</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">index</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">import</span>: <span class="pl-kos">[</span><span class="pl-s1">paths</span><span class="pl-kos">.</span><span class="pl-c1">appIndexJs</span><span class="pl-kos">,</span> ...<span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">isEnvDevelopment</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-c1">!</span><span class="pl-s1">shouldUseReactRefresh</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-kos">[</span><span class="pl-s1">webpackDevClientEntry</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">||</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-c1">runtime</span>: <span class="pl-s">'runtime'</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">app</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">import</span>: <span class="pl-s1">paths</span><span class="pl-kos">.</span><span class="pl-c1">appAppTsx</span><span class="pl-kos">,</span>
        <span class="pl-c1">dependOn</span>: <span class="pl-s">'index'</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-s1">output</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">filename</span>: <span class="pl-s">'/js/[name].js'</span><span class="pl-kos">,</span>
      <span class="pl-c1">globalObject</span>: <span class="pl-s">'window'</span><span class="pl-kos">,</span>
      <span class="pl-c1">library</span>: <span class="pl-kos">{</span>
        <span class="pl-c">// name: 'index',</span>
        <span class="pl-c1">type</span>: <span class="pl-s">'window'</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">iife</span>: <span class="pl-c1">true</span>
    <span class="pl-kos">}</span>
    <span class="pl-kos">[</span>...<span class="pl-kos">]</span></pre></div>
<p dir="auto">My <code class="notranslate">runtime</code> &amp; <code class="notranslate">index</code> are injected in the html and loaded first then I append to the document a script element with <code class="notranslate">app.js</code> file.<br>
This one executing and failed on the last <code class="notranslate">if</code> since <code class="notranslate">__webpack_exports__</code> is undefined<br>
(By the way I don't really know why id does not crash on the <code class="notranslate">for</code> but whatever)</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/******/ function(__webpack_require__) { // webpackRuntimeModules
/******/ &quot;use strict&quot;;
/******/ 
/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
/******/ __webpack_require__.O(0, [&quot;vendors-node_modules_ant-design_icons_es_components_Icon_js-node_modules_ant-design_icons_es_-64c2f1&quot;,&quot;vendors-node_modules_css-loader_dist_runtime_api_js-node_modules_css-loader_dist_runtime_cssW-2d1059&quot;,&quot;index&quot;], function() { return __webpack_exec__(&quot;./src/App.tsx&quot;), __webpack_exec__(&quot;./node_modules/webpack/hot/dev-server.js&quot;); });
/******/ var __webpack_exports__ = __webpack_require__.O();
/******/ var __webpack_export_target__ = window;
/******/ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
/******/ if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, &quot;__esModule&quot;, { value: true });
/******/ }"><pre class="notranslate"><span class="pl-c">/******/</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-c">// webpackRuntimeModules</span>
<span class="pl-c">/******/</span> <span class="pl-s">"use strict"</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span> 
<span class="pl-c">/******/</span> <span class="pl-k">var</span> <span class="pl-en">__webpack_exec__</span> <span class="pl-c1">=</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">moduleId</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">__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">moduleId</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
<span class="pl-c">/******/</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">O</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-s">"vendors-node_modules_ant-design_icons_es_components_Icon_js-node_modules_ant-design_icons_es_-64c2f1"</span><span class="pl-kos">,</span><span class="pl-s">"vendors-node_modules_css-loader_dist_runtime_api_js-node_modules_css-loader_dist_runtime_cssW-2d1059"</span><span class="pl-kos">,</span><span class="pl-s">"index"</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-k">function</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-en">__webpack_exec__</span><span class="pl-kos">(</span><span class="pl-s">"./src/App.tsx"</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-en">__webpack_exec__</span><span class="pl-kos">(</span><span class="pl-s">"./node_modules/webpack/hot/dev-server.js"</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-c">/******/</span> <span class="pl-k">var</span> <span class="pl-s1">__webpack_exports__</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">.</span><span class="pl-en">O</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span> <span class="pl-k">var</span> <span class="pl-s1">__webpack_export_target__</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</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-k">in</span> <span class="pl-s1">__webpack_exports__</span><span class="pl-kos">)</span> <span class="pl-s1">__webpack_export_target__</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">__webpack_exports__</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-c">/******/</span> <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_exports__</span><span class="pl-kos">.</span><span class="pl-c1">__esModule</span><span class="pl-kos">)</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">defineProperty</span><span class="pl-kos">(</span><span class="pl-s1">__webpack_export_target__</span><span class="pl-kos">,</span> <span class="pl-s">"__esModule"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">value</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/******/</span> <span class="pl-kos">}</span></pre></div>
<p dir="auto">I don't have a reproduction case for you but my <code class="notranslate">index.js</code> is relatively simple and my <code class="notranslate">app.js</code> is bundling the rest of the app (a react app).<br>
Basically what we are doing is loading the app only if we support the browser and if not redirect the user to a warning/faq/tuto page.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var userAgent = window.navigator.userAgent

if (
  userAgent.indexOf('MSIE ') &gt;= 0
  || userAgent.indexOf('Trident/') &gt;= 0
  || userAgent.indexOf('Edge/') &gt;= 0
) {
  window.location.href = '/non-supported-browser.html'
} else {
  window._startLoading() // Just styling &amp; animation
  var script = document.createElement('script')
  script.src = '/js/app.js'
  script.defer = true
  document.head.appendChild(script)
}"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">userAgent</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">navigator</span><span class="pl-kos">.</span><span class="pl-c1">userAgent</span>

<span class="pl-k">if</span> <span class="pl-kos">(</span>
  <span class="pl-s1">userAgent</span><span class="pl-kos">.</span><span class="pl-en">indexOf</span><span class="pl-kos">(</span><span class="pl-s">'MSIE '</span><span class="pl-kos">)</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span>
  <span class="pl-c1">||</span> <span class="pl-s1">userAgent</span><span class="pl-kos">.</span><span class="pl-en">indexOf</span><span class="pl-kos">(</span><span class="pl-s">'Trident/'</span><span class="pl-kos">)</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span>
  <span class="pl-c1">||</span> <span class="pl-s1">userAgent</span><span class="pl-kos">.</span><span class="pl-en">indexOf</span><span class="pl-kos">(</span><span class="pl-s">'Edge/'</span><span class="pl-kos">)</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span>
<span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">location</span><span class="pl-kos">.</span><span class="pl-c1">href</span> <span class="pl-c1">=</span> <span class="pl-s">'/non-supported-browser.html'</span>
<span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
  <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-en">_startLoading</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c">// Just styling &amp; animation</span>
  <span class="pl-k">var</span> <span class="pl-s1">script</span> <span class="pl-c1">=</span> <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">createElement</span><span class="pl-kos">(</span><span class="pl-s">'script'</span><span class="pl-kos">)</span>
  <span class="pl-s1">script</span><span class="pl-kos">.</span><span class="pl-c1">src</span> <span class="pl-c1">=</span> <span class="pl-s">'/js/app.js'</span>
  <span class="pl-s1">script</span><span class="pl-kos">.</span><span class="pl-c1">defer</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span>
  <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-c1">head</span><span class="pl-kos">.</span><span class="pl-en">appendChild</span><span class="pl-kos">(</span><span class="pl-s1">script</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">I did multiple try and not found yet a proper way to solve this issue so I really hope you can give me some help :)</p>
<p dir="auto">Hi sokra,</p>
<p dir="auto">I just got involved in another JS project and decided to stick with the tools I am familiar with, i.e. webpack, among others. Unfortunately when I created a new project I ran into some strange errors I could not explain. I ended up cleaning my old project of all generated content (npm &amp; jam modules) and updated the dependencies. Now with <code class="notranslate">node-jquery 1.8.3</code> my old project won't build at all. When I try to webpack the following minimal example</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// main.js
'use strict';

/*global require:true */
require = require('enhanced-require')(module, {
    recursive: true
});

var $ = require('jquery');"><pre class="notranslate"><code class="notranslate">// main.js
'use strict';

/*global require:true */
require = require('enhanced-require')(module, {
    recursive: true
});

var $ = require('jquery');
</code></pre></div>
<p dir="auto">I get the following warnings:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="WARNING: A file in context was excluded because of error: Error: File &quot;&lt;project root&gt;\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level1\core.js&quot; parsing failed: Error: Line 418: Unexpected token )
WARNING: A file in context was excluded because of error: Error: File &quot;&lt;project root&gt;\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level2\html.js&quot; parsing failed: Error: Line 446: Unexpected token )
WARNING: Cannot find module 'node-htmlparser/lib/node-htmlparser'
 Error: Module &quot;node-htmlparser/lib/node-htmlparser&quot; not found in context &quot;&lt;project root&gt;\node_modules\jquery\node
_modules\jsdom\lib\jsdom\browser&quot;
  Error: &lt;project root&gt;\node_modules\webpack\buildin\node-htmlparser\lib\node-htmlparser is not a directory
 @ &lt;project root&gt;\node_modules\jquery\node_modules\jsdom\lib\jsdom\browser\index.js (line 336, column 24)
WARNING: Cannot find module 'tls'
 Error: Module &quot;tls&quot; not found in context &quot;&lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\requ
est&quot;
  Error: Non of this files exists: &lt;project root&gt;\node_modules\webpack\buildin\tls-webpack, &lt;project root&gt;
\node_modules\webpack\buildin\tls-webpack.webpack.js, &lt;project root&gt;
\node_modules\webpack\buildin\tls-webpack.web.js, &lt;project root&gt;\node_modules\webpack\buildin\tls-webpack.js
 @ &lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 44, column 8)
WARNING: A file in context was excluded because of error: Error: File &quot;&lt;project root&gt;\node_modules\jquery\node_mod
ules\contextify\node_modules\bindings\README.md&quot; parsing failed: Error: Line 2: Unexpected token ===
WARNING: Cannot find module 'https'
 Error: Module &quot;https&quot; not found in context &quot;&lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\re
quest&quot;
  Error: Non of this files exists: &lt;project root&gt;\node_modules\webpack\buildin\https, &lt;project root&gt;
\node_modules\webpack\buildin\https.webpack.js, &lt;project root&gt;\node_module
s\webpack\buildin\https.web.js, &lt;project root&gt;\node_modules\webpack\buildin\https.js
 @ &lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 40, column 10)"><pre class="notranslate"><code class="notranslate">WARNING: A file in context was excluded because of error: Error: File "&lt;project root&gt;\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level1\core.js" parsing failed: Error: Line 418: Unexpected token )
WARNING: A file in context was excluded because of error: Error: File "&lt;project root&gt;\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level2\html.js" parsing failed: Error: Line 446: Unexpected token )
WARNING: Cannot find module 'node-htmlparser/lib/node-htmlparser'
 Error: Module "node-htmlparser/lib/node-htmlparser" not found in context "&lt;project root&gt;\node_modules\jquery\node
_modules\jsdom\lib\jsdom\browser"
  Error: &lt;project root&gt;\node_modules\webpack\buildin\node-htmlparser\lib\node-htmlparser is not a directory
 @ &lt;project root&gt;\node_modules\jquery\node_modules\jsdom\lib\jsdom\browser\index.js (line 336, column 24)
WARNING: Cannot find module 'tls'
 Error: Module "tls" not found in context "&lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\requ
est"
  Error: Non of this files exists: &lt;project root&gt;\node_modules\webpack\buildin\tls-webpack, &lt;project root&gt;
\node_modules\webpack\buildin\tls-webpack.webpack.js, &lt;project root&gt;
\node_modules\webpack\buildin\tls-webpack.web.js, &lt;project root&gt;\node_modules\webpack\buildin\tls-webpack.js
 @ &lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 44, column 8)
WARNING: A file in context was excluded because of error: Error: File "&lt;project root&gt;\node_modules\jquery\node_mod
ules\contextify\node_modules\bindings\README.md" parsing failed: Error: Line 2: Unexpected token ===
WARNING: Cannot find module 'https'
 Error: Module "https" not found in context "&lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\re
quest"
  Error: Non of this files exists: &lt;project root&gt;\node_modules\webpack\buildin\https, &lt;project root&gt;
\node_modules\webpack\buildin\https.webpack.js, &lt;project root&gt;\node_module
s\webpack\buildin\https.web.js, &lt;project root&gt;\node_modules\webpack\buildin\https.js
 @ &lt;project root&gt;\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 40, column 10)
</code></pre></div>
<p dir="auto">plus a ton of errors like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR: Cannot find module '../../../lib/numeric'
 Error: Error: Module &quot;jshint&quot; not found in context &quot;&lt;project root&gt;\src\client\numeric&quot;
  Error: &lt;project root&gt;\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
 @ &lt;project root&gt;\src\client\numeric\LinearSolver.js (line 7, column 36)
ERROR: Cannot find module '../../../../lib/spin'
 Error: Error: Module &quot;jshint&quot; not found in context &quot;&lt;project root&gt;\src\client\view\recipe&quot;
  Error: &lt;project root&gt;\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
 @ &lt;project root&gt;\src\client\view\recipe\RecipeListView.js (line 9, column 11)
ERROR: Cannot find module 'fs'
 Error: Module &quot;fs&quot; not found in context &quot;&lt;project root&gt;\node_modules\jquery\node_modules\xmlhttprequest\lib&quot;
  Error: &lt;project root&gt;\node_modules\webpack\buildin\fs is not a directory
 @ &lt;project root&gt;\node_modules\jquery\node_modules\xmlhttprequest\lib\XMLHttpRequest.js (line 16, column 9)"><pre class="notranslate"><code class="notranslate">ERROR: Cannot find module '../../../lib/numeric'
 Error: Error: Module "jshint" not found in context "&lt;project root&gt;\src\client\numeric"
  Error: &lt;project root&gt;\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
 @ &lt;project root&gt;\src\client\numeric\LinearSolver.js (line 7, column 36)
ERROR: Cannot find module '../../../../lib/spin'
 Error: Error: Module "jshint" not found in context "&lt;project root&gt;\src\client\view\recipe"
  Error: &lt;project root&gt;\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
 @ &lt;project root&gt;\src\client\view\recipe\RecipeListView.js (line 9, column 11)
ERROR: Cannot find module 'fs'
 Error: Module "fs" not found in context "&lt;project root&gt;\node_modules\jquery\node_modules\xmlhttprequest\lib"
  Error: &lt;project root&gt;\node_modules\webpack\buildin\fs is not a directory
 @ &lt;project root&gt;\node_modules\jquery\node_modules\xmlhttprequest\lib\XMLHttpRequest.js (line 16, column 9)
</code></pre></div>
<p dir="auto">For this example I <code class="notranslate">npm install</code>ed the latest versions of <code class="notranslate">jquery</code>, <code class="notranslate">webpack</code>, <code class="notranslate">enhanced-require</code> (node_modules) and <code class="notranslate">jam install</code>ed <code class="notranslate">jquery</code> (web_modules). Do you happen to have an idea of what went wrong here?</p>