Issue 1:
Bug report

As written on the title I have the issue of having __webpack_exports__ that is undefined when loading (later) a second entry point.

I'm using the latest lib versions webpack@5.35.0 and webpack-dev-server@3.11.2 on node v15.11.0 on Linux.

I have a very simple config:

entry: {
index: {
import: [paths.appIndexJs, ...((isEnvDevelopment && !shouldUseReactRefresh && [webpackDevClientEntry]) || [])],
runtime: 'runtime'
},
app: {
import: paths.appAppTsx,
dependOn: 'index'
}
},
output: {
filename: '/js/[name].js',
globalObject: 'window',
library: {
// name: 'index',
type: 'window'
},
iife: true
}
[...]

My runtime & index are injected in the html and loaded first then I append to the document a script element with app.js file.

This one executing and failed on the last if since __webpack_exports__ is undefined

(By the way I don't really know why id does not crash on the for but whatever)

/******/ function(__webpack_require__) { // webpackRuntimeModules
/******/ "use strict";
/******/
/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
/******/ __webpack_require__.O(0, ["vendors-node_modules_ant-design_icons_es_components_Icon_js-node_modules_ant-design_icons_es_-64c2f1","vendors-node_modules_css-loader_dist_runtime_api_js-node_modules_css-loader_dist_runtime_cssW-2d1059","index"], function() { return __webpack_exec__("./src/App.tsx"), __webpack_exec__("./node_modules/webpack/hot/dev-server.js"); });
/******/ 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__, "__esModule", { value: true });
/******/ }

I don't have a reproduction case for you but my index.js is relatively simple and my app.js is bundling the rest of the app (a react app).

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.

var userAgent = window.navigator.userAgent

if (
userAgent.indexOf('MSIE ') >= 0
|| userAgent.indexOf('Trident/') >= 0
|| userAgent.indexOf('Edge/') >= 0
) {
window.location.href = '/non-supported-browser.html'
} else {
window._startLoading() // Just styling & animation
var script = document.createElement('script')
script.src = '/js/app.js'
script.defer = true
document.head.appendChild(script)
}

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 :)

Issue 2:
Hi sokra,

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 & jam modules) and updated the dependencies. Now with node-jquery 1.8.3 my old project won't build at all. When I try to webpack the following minimal example

// main.js
'use strict';

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

var $ = require('jquery');

I get the following warnings:

WARNING: A file in context was excluded because of error: Error: File "<project root>\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 "<project root>\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 "<project root>\node_modules\jquery\node
_modules\jsdom\lib\jsdom\browser"
Error: <project root>\node_modules\webpack\buildin\node-htmlparser\lib\node-htmlparser is not a directory
@ <project root>\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 "<project root>\node_modules\jquery\node_modules\jsdom\node_modules\requ
est"
Error: Non of this files exists: <project root>\node_modules\webpack\buildin\tls-webpack, <project root>
\node_modules\webpack\buildin\tls-webpack.webpack.js, <project root>
\node_modules\webpack\buildin\tls-webpack.web.js, <project root>\node_modules\webpack\buildin\tls-webpack.js
@ <project root>\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 "<project root>\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 "<project root>\node_modules\jquery\node_modules\jsdom\node_modules\re
quest"
Error: Non of this files exists: <project root>\node_modules\webpack\buildin\https, <project root>
\node_modules\webpack\buildin\https.webpack.js, <project root>\node_module
s\webpack\buildin\https.web.js, <project root>\node_modules\webpack\buildin\https.js
@ <project root>\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 40, column 10)

plus a ton of errors like:

ERROR: Cannot find module '../../../lib/numeric'
Error: Error: Module "jshint" not found in context "<project root>\src\client\numeric"
Error: <project root>\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
@ <project root>\src\client\numeric\LinearSolver.js (line 7, column 36)
ERROR: Cannot find module '../../../../lib/spin'
Error: Error: Module "jshint" not found in context "<project root>\src\client\view\recipe"
Error: <project root>\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
@ <project root>\src\client\view\recipe\RecipeListView.js (line 9, column 11)
ERROR: Cannot find module 'fs'
Error: Module "fs" not found in context "<project root>\node_modules\jquery\node_modules\xmlhttprequest\lib"
Error: <project root>\node_modules\webpack\buildin\fs is not a directory
@ <project root>\node_modules\jquery\node_modules\xmlhttprequest\lib\XMLHttpRequest.js (line 16, column 9)

For this example I npm installed the latest versions of jquery, webpack, enhanced-require (node_modules) and jam installed jquery (web_modules). Do you happen to have an idea of what went wrong here?