github evanw/esbuild v0.14.54

latest releases: v0.24.0, v0.23.1, v0.23.0...
2 years ago
  • Fix optimizations for calls containing spread arguments (#2445)

    This release fixes the handling of spread arguments in the optimization of /* @__PURE__ */ comments, empty functions, and identity functions:

    // Original code
    function empty() {}
    function identity(x) { return x }
    /* @__PURE__ */ a(...x)
    /* @__PURE__ */ new b(...x)
    empty(...x)
    identity(...x)
    
    // Old output (with --minify --tree-shaking=true)
    ...x;...x;...x;...x;
    
    // New output (with --minify --tree-shaking=true)
    function identity(n){return n}[...x];[...x];[...x];identity(...x);

    Previously esbuild assumed arguments with side effects could be directly inlined. This is almost always true except for spread arguments, which are not syntactically valid on their own and which have the side effect of causing iteration, which might have further side effects. Now esbuild will wrap these elements in an unused array so that they are syntactically valid and so that the iteration side effects are preserved.

Don't miss a new esbuild release

NewReleases is sending notifications on new releases.