esbuild 0.14.6
-
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
falsebefore being minified andtrueafter 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"" + barchanged the meaning of the expression. Template string interpolation always callstoStringwhile string addition may callvalueOfinstead. This unused expression is now minified to`${bar}`, which is slightly longer but which avoids the behavior change. -
Allow
keyof/readonly/inferin 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.metaif it's replaced (#1868)It's possible to replace the
import.metaexpression using the--define:feature. Previously doing that still warned that theimport.metasyntax was not supported when targeting ES5. With this release, there will no longer be a warning in this case.