esbuild
0.28.2 · 8 Aug 2026MIT439.7M / weekRepositoryHomepagenpmAtom feed
0.28.2 is the newest release of 0.14.x.
In short
1 new2 fixed1 changed
Security
1 advisory affects 0.14.26
- Moderateesbuild enables any website to send any requests to the development server and read the responseGHSA-67mh-4wv8-2f99 · 10 Feb 2025No fix yet
Release note
Fix a tree shaking regression regarding
vardeclarations (#2080, #2085, #2098, #2099)Version 0.14.8 of esbuild enabled removal of duplicate function declarations when minification is enabled (see #610):
// Original code function x() { return 1 } console.log(x()) function x() { return 2 } // Output (with --minify-syntax) console.log(x()); function x() { return 2; }This transformation is safe because function declarations are "hoisted" in JavaScript, which means they are all done first before any other code is evaluted. This means the last function declaration will overwrite all previous function declarations with the same name.
However, this introduced an unintentional regression for
vardeclarations in which all but the last declaration was dropped if tree-shaking was enabled. This only happens for top-levelvardeclarations that re-declare the same variable multiple times. This regression has now been fixed:// Original code var x = 1 console.log(x) var x = 2 // Old output (with --tree-shaking=true) console.log(x); var x = 2; // New output (with --tree-shaking=true) var x = 1; console.log(x); var x = 2;
This case now has test coverage.
Add support for parsing "instantiation expressions" from TypeScript 4.7
The upcoming version of TypeScript now lets you specify
<...>type parameters on a JavaScript identifier without using a call expression:const ErrorMap = Map<string, Error>; // new () => Map<string, Error> const errorMap = new ErrorMap(); // Map<string, Error>
With this release, esbuild can now parse these new type annotations. This feature was contributed
Avoid
new Functionin esbuild's library codeSome JavaScript environments such as Cloudflare Workers or Deno Deploy don't allow
new Functionbecause they disallow dynamic JavaScript evaluation. Previously esbuild's WebAssembly-based library used this to construct the WebAssembly worker function. With this release, the code is now inlined without usingnew Functionso it will be able to run even when this restriction is in place.Drop superfluous
__name()callsWhen the
--keep-namesoption is specified, esbuild inserts calls to a__namehelper function to ensure that the.nameproperty on function and class objects remains consistent even if the function or class name is renamed to avoid a name collision or because name minification is enabled. With this release, esbuild will now try to omit these calls to the__namehelper function when the name of the function or class object was not renamed during the linking process after all:// Original code import { foo as foo1 } from 'data:text/javascript,export function foo() { return "foo1" }' import { foo as foo2 } from 'data:text/javascript,export function foo() { return "foo2" }' console.log(foo1.name, foo2.name) // Old output (with --bundle --keep-names) (() => { var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); function foo() { return "foo1"; } __name(foo, "foo"); function foo2() { return "foo2"; } __name(foo2, "foo"); console.log(foo.name, foo2.name); })(); // New output (with --bundle --keep-names) (() => { var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); function foo() { return "foo1"; } function foo2() { return "foo2"; } __name(foo2, "foo"); console.log(foo.name, foo2.name); })();Notice how one of the calls to
__nameis now no longer printed. This change was contributed
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.