github evanw/esbuild v0.14.6

latest releases: v0.24.0, v0.23.1, v0.23.0...
2 years ago
  • Fix a minifier bug with BigInt literals

    Previously expression simplification optimizations in the minifier incorrectly assumed that numeric operators always return numbers. This used to be true but has no longer been true since the introduction of BigInt literals in ES2020. Now numeric operators can return either a number or a BigInt depending on the arguments. This oversight could potentially have resulted in behavior changes. For example, this code printed false before being minified and true after being minified because esbuild shortened === to == under the false assumption that both operands were numbers:

    var x = 0;
    console.log((x ? 2 : -1n) === -1);

    The type checking logic has been rewritten to take into account BigInt literals in this release, so this incorrect simplification is no longer applied.

  • Enable removal of certain unused template literals (#1853)

    This release contains improvements to the minification of unused template literals containing primitive values:

    // Original code
    `${1}${2}${3}`;
    `${x ? 1 : 2}${y}`;
    
    // Old output (with --minify)
    ""+1+2+3,""+(x?1:2)+y;
    
    // New output (with --minify)
    x,`${y}`;

    This can arise when the template literals are nested inside of another function call that was determined to be unnecessary such as an unused call to a function marked with the /* @__PURE__ */ pragma.

    This release also fixes a bug with this transformation where minifying the unused expression `foo ${bar}` into "" + bar changed the meaning of the expression. Template string interpolation always calls toString while string addition may call valueOf instead. This unused expression is now minified to `${bar}`, which is slightly longer but which avoids the behavior change.

  • Allow keyof/readonly/infer in TypeScript index signatures (#1859)

    This release fixes a bug that prevented these keywords from being used as names in index signatures. The following TypeScript code was previously rejected, but is now accepted:

    interface Foo {
      [keyof: string]: number
    }

    This fix was contributed by @magic-akari.

  • Avoid warning about import.meta if it's replaced (#1868)

    It's possible to replace the import.meta expression using the --define: feature. Previously doing that still warned that the import.meta syntax was not supported when targeting ES5. With this release, there will no longer be a warning in this case.

Don't miss a new esbuild release

NewReleases is sending notifications on new releases.