Const reassignment in production build
See original GitHub issueBug report
What is the current behavior?
Webpack generates code using a const
variable and then attempts to re-assign it. I suppose this could be due to the vue dependencies I’m using - but this code very much appears to be generated by webpack itself (or at least, half of it is, and then the libraryExport
option attempts to overwrite it).
It seems like this shouldn’t be creating a block-scoped variable here at all, and assigning it to the global variable for the named library export.
If the current behavior is a bug, please provide the steps to reproduce.
Repo with minimal reproduction: https://github.com/richinfante/webpack-bug-repro
I’ve disabled the terser plugin in the test repo so output isn’t minified & optimized.
In short, running a production build generates the following code, which yields a syntax error in browsers:
/* harmony default export */ const empty_component = (component.exports);
empty_component = __webpack_exports__.default;
What is the expected behavior?
Webpack shouldn’t generate code that tries to re-assign a const variable.
Other relevant information: webpack version: 5.28.0 Node.js version: v14.16.0 Operating System: Arch Linux (5.11.8-arch1-1) Additional tools: Vue 2.6.12
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
as workaround: rename your
empty_component.vue
file to something else.Marked as
critical-bug
, we will try to fix it in near future