Have you used AI?
No
Bug Description
#20773 adds emitting the lines
(Object.getOwnPropertyDescriptor(u, "name") || {}).writable || Object.defineProperty(u, "name", { value: "default", configurable: true });
or
Object.defineProperty(u, "name", { value: "default", configurable: true });
for unnamed default exports. When creating as ES-library, using many .js files as input, where the .js files use export default, to the user of the libray it is irrelevant, if the library is programmed internally with default or named exports, or one big file - using or not using webpack to create the library/delivered .js file. It would be also strange, if a library documents that a symbol it exposes (indirectly) has .name == default.
- When creating ES libraries, do not set property
name to value "default" for internal symbols. It just increases the size of the concatenated output unnecessary.
Link to Minimal Reproduction and step to reproduce
With (note that this is not the default branch!):
git clone -bpropdescr https://github.com/dilyanpalauzov/webpack-i20146
cd webpack-i20146/
npm update && npm run bundle
Expected Behavior
The output includes
(Object.getOwnPropertyDescriptor(u, "name") || {}).writable || Object.defineProperty(u, "name", { value: "default", configurable: true });
with webpack 5.106.1. The same input does not include the above line, when webpack 5.105.4 is used (after npm install webpack@5.105.4).
The complete output with 5.106.1 is:
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/************************************************************************/
;// ./src/u.js
/* harmony default export */ const u = (class {
constructor() {
console.log("UU");
}
});
(Object.getOwnPropertyDescriptor(u, "name") || {}).writable || Object.defineProperty(u, "name", { value: "default", configurable: true });
;// ./src/index.js
/* harmony default export */ const src = (u);
export { src as default };
If the content of u.js is changed to
export default function() {
console.log("UU")
}
then the output after /************************************************************************/ is with 5.106.1:
;// ./src/u.js
Object.defineProperty(u, "name", { value: "default", configurable: true });
/* harmony default export */ function u() {
console.log("UU")
}
;// ./src/index.js
/* harmony default export */ const src = (u);
export { src as default };
and with 5.105.4 the line Object.defineProperty(u, "name", { value: "default", configurable: true }); is not included in the output.
Actual Behavior
Expected behaviour is not to define .name = "default" for library internal symbols — it has worked that way for many years without problems.
Environment
System:
OS: Linux 6.19
Binaries:
Node: 22.22.0 - /usr/bin/node
Yarn: 4.6.0 - /usr/local/bin/yarn
npm: 10.9.4 - /usr/bin/npm
Using alternating versions 5.105.4 ad 5.106.1
Is this a regression?
Yes (please specify version below)
Last Working Version
5.105.4
Additional Context
No response
Have you used AI?
No
Bug Description
#20773 adds emitting the lines
or
for unnamed
defaultexports. When creating as ES-library, using many.jsfiles as input, where the.jsfiles useexport default, to the user of the libray it is irrelevant, if the library is programmed internally with default or named exports, or one big file - using or not using webpack to create the library/delivered.jsfile. It would be also strange, if a library documents that a symbol it exposes (indirectly) has.name == default.nameto value"default"for internal symbols. It just increases the size of the concatenated output unnecessary.Link to Minimal Reproduction and step to reproduce
With (note that this is not the default branch!):
Expected Behavior
The output includes
with webpack 5.106.1. The same input does not include the above line, when webpack 5.105.4 is used (after
npm install webpack@5.105.4).The complete output with 5.106.1 is:
If the content of u.js is changed to
then the output after
/************************************************************************/is with 5.106.1:and with 5.105.4 the line
Object.defineProperty(u, "name", { value: "default", configurable: true });is not included in the output.Actual Behavior
Expected behaviour is not to define
.name = "default"for library internal symbols — it has worked that way for many years without problems.Environment
System: OS: Linux 6.19 Binaries: Node: 22.22.0 - /usr/bin/node Yarn: 4.6.0 - /usr/local/bin/yarn npm: 10.9.4 - /usr/bin/npm Using alternating versions 5.105.4 ad 5.106.1Is this a regression?
Yes (please specify version below)
Last Working Version
5.105.4
Additional Context
No response