babel-plugin-transform-decorators-legacy icon indicating copy to clipboard operation
babel-plugin-transform-decorators-legacy copied to clipboard

Incorrect local name w/ native classes & babel-minify

Open developit opened this issue 6 years ago • 0 comments

Looks like the local name gets mangled with babel-minify, but not references to it.

  • This only happens when classes are not transpiled (eg: no preset, or env preset with >4%) and minify is used.
  • Changing to an expression (const Foo = @hello class {}) works, though the name is not mangled
  • The effect is still present when no decorator is used.

It seems like the outer variable name assigned by the decorators plugin is being mangled when it shouldn't be (since without the decorator it is unmangled).

Input Output
@hello
class Foo {};
new Foo();
var _class;
let a = hello(_class = class Foo {}) || _class;
new Foo();

Babel REPL Link

developit avatar Jan 04 '19 14:01 developit