npm esbuild 0.14.16
v0.14.16

latest releases: 0.24.0, 0.23.1, 0.23.0...
2 years ago
  • Support property name mangling with some TypeScript syntax features

    The newly-released --mangle-props= feature previously only affected JavaScript syntax features. This release adds support for using mangle props with certain TypeScript syntax features:

    • TypeScript parameter properties

      Parameter properties are a TypeScript-only shorthand way of initializing a class field directly from the constructor argument list. Previously parameter properties were not treated as properties to be mangled. They should now be handled correctly:

      // Original code
      class Foo {
        constructor(public foo_) {}
      }
      new Foo().foo_;
      
      // Old output (with --minify --mangle-props=_)
      class Foo{constructor(c){this.foo_=c}}new Foo().o;
      
      // New output (with --minify --mangle-props=_)
      class Foo{constructor(o){this.c=o}}new Foo().c;
    • TypeScript namespaces

      Namespaces are a TypeScript-only way to add properties to an object. Previously exported namespace members were not treated as properties to be mangled. They should now be handled correctly:

      // Original code
      namespace ns {
        export let foo_ = 1;
        export function bar_(x) {}
      }
      ns.bar_(ns.foo_);
      
      // Old output (with --minify --mangle-props=_)
      var ns;(e=>{e.foo_=1;function t(a){}e.bar_=t})(ns||={}),ns.e(ns.o);
      
      // New output (with --minify --mangle-props=_)
      var ns;(e=>{e.e=1;function o(p){}e.t=o})(ns||={}),ns.t(ns.e);
  • Fix property name mangling for lowered class fields

    This release fixes a compiler crash with --mangle-props= and class fields that need to be transformed to older versions of JavaScript. The problem was that doing this is an unusual case where the mangled property name must be represented as a string instead of as a property name, which previously wasn't implemented. This case should now work correctly:

    // Original code
    class Foo {
      static foo_;
    }
    Foo.foo_ = 0;
    
    // New output (with --mangle-props=_ --target=es6)
    class Foo {
    }
    __publicField(Foo, "a");
    Foo.a = 0;

Don't miss a new esbuild release

NewReleases is sending notifications on new releases.