-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
If..Else preserve vars from the removed Block #52
Conversation
+ (Close #48) + dead-code-elimination
node.alternate = null; | ||
node.test = t.unaryExpression("!", test, true); | ||
consequent.replaceWith(alternate.node); | ||
alternate.skip(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, is it safe to skip this, as the node will be inserted in consequent
and will go through other plugins and the alternate
node removed will be skipped. Should there be a test case for this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, can you please add a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: babel-traverse marks it as shouldSkip when .remove
LGTM |
A test case to verify that optimizations are applied when an empty consequent block statement is replaced with the alternate statement.
Now there are 2 failing test cases because of indentation issues, help! |
Ok, I'll merge and check tests locally |
This introduced some regressions, looking at it now. You can see the failing tests here: https://travis-ci.com/amasad/babel-minify/jobs/46513934 |
This somehow makes one test case fail due to some indentation issue.
I'm doing
path.skip()
the paths that are removed - is that safe to do ?