Rich-Harris / butternut

The fast, future-friendly minifier
https://butternut.now.sh
MIT License
1.17k stars 17 forks source link

Bug w/ async + arrow functions + object destructuring #170

Open jeffposnick opened 7 years ago

jeffposnick commented 7 years ago

butternut 0.1.0 minifies the following code

const asyncArrowFunction = async ({value}) => {
  console.log(`value is ${value}`);
};

asyncArrowFunction({value: 1});

to

let asyncArrowFunction=async {value:g})=>{console.log(`value is ${g}`)};asyncArrowFunction({value:1})

The async { in that output should be async ({, and without that missing ( character, the output isn't valid JavaScript.

This bug seems specific to the combination of all three of the async keyword, arrow functions, and object destructuring of parameter passed to the function. If only two of those are used (e.g. async and arrow functions, without object destructuring for the parameter), then the output minifies properly.