Skip to content
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

Account for removal of consequent inside ternary for no-console plugin. Fixes #374 #375

Closed
wants to merge 1 commit into from

Conversation

DrewML
Copy link
Member

@DrewML DrewML commented Jan 14, 2017

Figured I'd take a whack at it. The ideal minified form of this would probably be:

// in
var foo = console.log ? console.log('lol') : someOtherFn;
// out
var foo = someOtherFn;

but I just went with what would fix the bug for now. Feedback welcome.

@boopathi
Copy link
Member

@boopathi
Copy link
Member

boopathi commented Jan 16, 2017

  • logical Expression - remove it
  • [ console.log() ] - can't remove - array length changes.
  • Conditional Expression - replace to void 0 and let minify-simplify change it to logical expression
  • If the parent is an ExpressionStatement, then remove it.

So, if it's any other expression other than logical expression, can't we just replace it with void 0 and let other plugins which handle void 0 (https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-remove-undefined) handle that ?

Edit:
Even for logical expressions we can just replace it with undefined

oliviertassinari added a commit to oliviertassinari/babel-plugin-transform-react-remove-prop-types that referenced this pull request Feb 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants