samualtnorman/hackmud-script-manager

Global class minification results in incorrect code

Closed this issue · 0 comments

The following code:

export default (context, args) => {
  return new Foo("bar");
}

class Foo {}

compiles to

function(){#FMCL||(#G.Foo=class{})
return new #G.Foo("bar")}

which is not correct -- this is parsed as (new #G).Foo("bar") as #G expands to a function call (__internals("«script name»")), resulting in new __internals("«script name»").Foo("bar") -- which applies the new targetting to the internal #G function, not the class constructor.