match icon indicating copy to clipboard operation
match copied to clipboard

This won't work with minified code

Open Morantron opened this issue 9 years ago • 1 comments

Hi! Nice lib! I used the same technique of lookiing up argument names in a project a long time ago, and had a similar issue. Basically, if you rely on stringified argument names, minifiers will change those names and your code won't work.


// before minification

let response = match(message, [
  hello => 'the value is hello',
  goodbye => 'hello to you too!',
  _ => 'something else'
])

// after minification

var response = match(message, [
  function(a) { return 'the value is hello' },
  function(a) { return 'hello to you too!'},
  function(a) {return 'something else' }
]);

Maybe implementing this as a babel plugin can solve this issue as well as performance one, since the switching won't happen at runtime.

Morantron avatar Jan 23 '16 11:01 Morantron

I wish the documentation on Babel plugins was better. Thanks for reporting this. Maybe I'll get time to make one!

zackify avatar Jan 23 '16 15:01 zackify