Rich-Harris / butternut

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

Bug: Whitespace before function name gets removed #131

Closed loilo closed 7 years ago

loilo commented 7 years ago

From trying to squash appbase-js.

This is kind of a regression error in 0.4.5.

Consider this input:

function fn () {
  return function any_fn ( any_var ){
    var any_var = 1
    any_fn( any_var )
  }()
}

In 0.4.4, Butternut removed the any_fn name of the inner function. This has been fixed in 0.4.5.

However, Butternut now collapses the whitespace between the function keyword and the any_fn (mangled to a) name:

Output:

function fn(){return functiona(b){var b=1;a(b)}()}