New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Superclass replaced with null
in production build
#17711
Comments
We've also hit this bug when trying to update Webpack, for us the failing code can be simplified to:
I did some regression testing: I see |
Yeah, it is a bug, PR welcome |
@alexander-akait @MattiasBuelens it seems that the code which is given by @MattiasBuelens contains comma(,) after |
@alexander-akait what are your thoughts on this |
@cherish2003 I think we miss something in inner graph when we handle classes, I don't look deeply on this, but yeah, I think we don't handle variables after |
Bug report
What is the current behavior?
When building the following JavaScript file with Webpack in production mode, it generates invalid code that throws a
TypeError
at runtime:The resulting code looks like this:
If the current behavior is a bug, please provide the steps to reproduce.
See https://github.com/MattiasBuelens/webpack-minify-issue for a full reproduction case, or open it on Stackblitz.
Run:
Then open the resulting app in a web browser. You should see the text "Running test...", and the following error will appear in the browser console:
What is the expected behavior?
You should see the text "Test succeeded!" in the web browser. The resulting app should not throw a
TypeError
.The app works fine when building in development mode, so changing
mode
to"development"
inwebpack.config.js
demonstrates the expected correct behavior.Other relevant information:
webpack version: 5.88.2
Node.js version: 18.18.0
Operating System: Windows 11 Pro 22H2 (build 22621.2283)
Additional tools: N/A
Initial investigation:
If you set
optimization.minimize
=false
, then you get:The "unused pure expression or super" comes from PureExpressionDependency.js, so the bug is probably somewhere around there.
Also interesting: if you split the variable declaration for
UnusedClass
andunusedVariable
into two separatevar
statements, the bug does not show up.The text was updated successfully, but these errors were encountered: