-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Constant folding in development builds #657
Comments
This is true, but why is this a problem? |
For the same reason that you explained in the linked issue. It throws off static analysis and bundling. It's just something that I noticed that didn't seem to work the way it "should". |
I see why you think it should fold, but there's certainly people who wouldn't want it to. Makes it easier to diff code before and after using --define flags in large projects, for instance. |
I was going off of what @evanw said in the other thread.
The reason that I brought it up was the incosistency in folding between tertiary operators and if statements |
Oh interesting, I didn't know about ternary folding. Personally I don't think it should fold. Thanks for the catch. It would be nice if it was consistent, whichever way it goes. |
This whole feature is motivated by these few lines of code in React, which makes doing this necessary. When not minifying, esbuild still does enough constant folding to be able to determine that |
Not removing dead code when not minifying makes a lot of sense, and I agree that the its the way to go. |
Sure, I can turn off dead code elimination for that specific case. Previously it was only done for expressions but not for statements. With this change it will now be done for all expressions except no longer for conditional expressions. |
I've noticed a case where the constant folding isn't happening where I thought it should.
It works great in tertirary operators, however it doesn't seem to fold with constant
if
conditions.Looking at #371 it appears like that should be folded properly.
If I enable minification, it does do the proper foldinig.
The text was updated successfully, but these errors were encountered: