match
match copied to clipboard
This won't work with minified code
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.
I wish the documentation on Babel plugins was better. Thanks for reporting this. Maybe I'll get time to make one!