Repository navigation
Description
Minimal repro repo: https://github.com/fregante/webpack-concat-fail-demo
Bug report
Module concatenation bails out simply when there are 2 entries in the config. This is the minimal repro. The diff shows the breaking point
{
devtool: 'source-map',
entry: {
a: './a',
+ b: './b',
},
optimization: {
concatenateModules: true,
}
};// This is the common imported module
export const isTrue = () => true;// Both a.js and b.js have this
import {isTrue} from './module';
isTrue()What is the current behavior?
The common import "module.js" is no longer concatenated when you have 2 entry points. Even the dist/a.js output changes simply after adding b: './b':
@@ -87,23 +87,34 @@
/******/ ({
/***/ "./a.js":
-/*!**************************!*\
- !*** ./a.js + 1 modules ***!
- \**************************/
+/*!**************!*\
+ !*** ./a.js ***!
+ \**************/
/*! no exports provided */
+/*! ModuleConcatenation bailout: Module is an entry point */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./module */ "./module.js");
-// CONCATENATED MODULE: ./module.js
-const isTrue = () => true;
-// CONCATENATED MODULE: ./a.js
+Object(_module__WEBPACK_IMPORTED_MODULE_0__["isTrue"])()
+
+/***/ }),
+
+/***/ "./module.js":
+/*!*******************!*\
+ !*** ./module.js ***!
+ \*******************/
+/*! exports provided: isTrue */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
-isTrue()
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isTrue", function() { return isTrue; });
+const isTrue = () => true;
/***/ })You can see the full diff output here: https://github.com/fregante/webpack-concat-fail-demo/commit/d3570f8648b339ca8f19c2770c6dcd0d9d9a2318
What is the expected behavior?
Having multiple entries should not affect the output of the first entry.
This is the regular output with just one entry point:
// CONCATENATED MODULE: ./module.js
const isTrue = () => true;
// CONCATENATED MODULE: ./a.js
isTrue();If the current behavior is a bug, please provide the steps to reproduce.
Other relevant information:
webpack version: 4.42.1
Node.js version: v12.15.0
Operating System: macOS 10.15.3
Additional tools:
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fregante commentedon Apr 16, 2020
Webpack v5.0.0-beta.13is affected by the same bugsokra commentedon Apr 16, 2020
Just because it's not concatenated it's not broken. The bundle should still behave the same.
You are requesting to improve that, it's not really a bug.
fregante commentedon Apr 16, 2020
The bundle isn't broken indeed, but the specific feature is (i.e. it isn't working as it should), therefore it is a bug... just not a "breaking bug" 😅
webpack-bot commentedon Jul 20, 2020
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
fregante commentedon Oct 24, 2020
This appears to be fixed in 5.2.0 🎉
fregante commentedon Oct 24, 2020
Here are the 2 outputted files in full:
alexander-akait commentedon Oct 24, 2020
Terser remove all junks for production mode
Regenerate package.lock and update webpack