Changelog
0.28.1
-
Disallow
\in local development server HTTP requests (GHSA-g7r4-m6w7-qqqr)This release fixes a security issue where HTTP requests to esbuild's local development server could traverse outside of the serve directory on Windows using a
\backslash character. It happened due to the use of Go'spath.Clean()function, which only handles Unix-style/characters. HTTP requests with paths containing\are no longer allowed.Thanks to @dellalibera for reporting this issue.
-
Add integrity checks to the Deno API (GHSA-gv7w-rqvm-qjhr)
The previous release of esbuild added integrity checks to esbuild's npm install script. This release also adds integrity checks to esbuild's Deno install script. Now esbuild's Deno API will also fail with an error if the downloaded esbuild binary contains something other than the expected content.
Note that esbuild's Deno API installs from
registry.npmjs.orgby default, but allows theNPM_CONFIG_REGISTRYenvironment variable to override this with a custom package registry. This change means that the esbuild executable served byNPM_CONFIG_REGISTRYmust now match the expected content.Thanks to @sondt99 for reporting this issue.
-
Avoid inlining
usingandawait usingdeclarations (#4482)Previously esbuild's minifier sometimes incorrectly inlined
usingandawait usingdeclarations into subsequent uses of that declaration, which then fails to dispose of the resource correctly. This bug happened because inlining was done forletandconstdeclarations by avoiding doing it forvardeclarations, which no longer worked when more declaration types were added. Here's an example:// Original code { using x = new Resource() x.activate() } // Old output (with --minify) new Resource().activate(); // New output (with --minify) {using e=new Resource;e.activate()} -
Fix module evaluation when an error is thrown (#4461, #4467)
If an error is thrown during module evaluation, esbuild previously didn't preserve the state of the module for subsequent module references. This was observable if
import()orrequire()is used to import a module multiple times. The thrown error is supposed to be thrown by every call toimport()orrequire(), not just the first. With this release, esbuild will now throw the same error every time you callimport()orrequire()on a module that throws during its evaluation. -
Fix some edge cases around the
newoperator (#4477)Previously esbuild incorrectly printed certain edge cases involving complex expressions inside the target of a
newexpression (specifically an optional chain and/or a tagged template literal). The generated code for thenewtarget was not correctly wrapped with parentheses, and either contained a syntax error or had different semantics. These edge cases have been fixed so that they now correctly wrap thenewtarget in parentheses. Here is an example of some affected code:// Original code new (foo()`bar`)() new (foo()?.bar)() // Old output new foo()`bar`(); new (foo())?.bar(); // New output new (foo())`bar`(); new (foo()?.bar)(); -
Fix renaming of nested
vardeclarations (#4471)This release fixes a bug where
vardeclarations in nested scopes that are hoisted up to module scope were not correctly being renamed during bundling. That could previously lead to name collisions when minification was disabled, which could potentially cause a behavior change. The bug has been fixed so that these hoisted declarations are now considered to be module-level symbols during the name collision avoidance pass. -
Emit
varinstead ofconstfor certain TypeScript-only constructs for ES5 (#4448)While esbuild doesn't generally support converting
consttovarfor ES5 due to nested scoping rules (which is currently a build-time error), esbuild previously incorrectly converted TypeScript-onlyimportassignment constructs into aconstdeclaration even when targeting ES5. With this release, esbuild will now usevarfor this case instead:// Original code import x = require('y') // Old output (with --target=es5) const x = require("y"); // New output (with --target=es5) var x = require("y");
0.28.0
-
Add support for
with { type: 'text' }imports (#4435)The import text proposal has reached stage 3 in the TC39 process, which means that it's recommended for implementation. It has also already been implemented by Deno and Bun. So with this release, esbuild also adds support for it. This behaves exactly the same as esbuild's existing
textloader. Here's an example:import string from './example.txt' with { type: 'text' } console.log(string) -
Add integrity checks to fallback download path (#4343)
Installing esbuild via npm is somewhat complicated with several different edge cases (see esbuild's documentation for details). If the regular installation of esbuild's platform-specific package fails, esbuild's install script attempts to download the platform-specific package itself (first with the
npmcommand, and then with a HTTP request toregistry.npmjs.orgas a last resort).This last resort path previously didn't have any integrity checks. With this release, esbuild will now verify that the hash of the downloaded binary matches the expected hash for the current release. This means the hashes for all of esbuild's platform-specific binary packages will now be embedded in the top-level
esbuildpackage. Hopefully this should work without any problems. But just in case, this change is being done as a breaking change release. -
Update the Go compiler from 1.25.7 to 1.26.1
This upgrade should not affect anything. However, there have been some significant internal changes to the Go compiler, so esbuild could potentially behave differently in certain edge cases:
- It now uses the new garbage collector that comes with Go 1.26.
- The Go compiler is now more aggressive with allocating memory on the stack.
- The executable format that the Go linker uses has undergone several changes.
- The WebAssembly build now unconditionally makes use of the sign extension and non-trapping floating-point to integer conversion instructions.
You can read the Go 1.26 release notes for more information.
0.27.7
-
Fix lowering of define semantics for TypeScript parameter properties (#4421)
The previous release incorrectly generated class fields for TypeScript parameter properties even when the configured target environment does not support class fields. With this release, the generated class fields will now be correctly lowered in this case:
// Original code class Foo { constructor(public x = 1) {} y = 2 } // Old output (with --loader=ts --target=es2021) class Foo { constructor(x = 1) { this.x = x; __publicField(this, "y", 2); } x; } // New output (with --loader=ts --target=es2021) class Foo { constructor(x = 1) { __publicField(this, "x", x); __publicField(this, "y", 2); } }
0.27.5
-
Fix for an async generator edge case (#4401, #4417)
Support for transforming async generators into the equivalent state machine was added in version 0.19.0. However, the generated state machine didn't work correctly when polling async generators concurrently, such as in the following code:
async function* inner() { yield 1; yield 2 } async function* outer() { yield* inner() } let gen = outer() for await (let x of [gen.next(), gen.next()]) console.log(x)Previously esbuild's output of the above code behaved incorrectly when async generators were transformed (such as with
--supported:async-generator=false). The transformation should be fixed starting with this release.This fix was contributed by @2767mr.
-
Fix a regression when
metafileis enabled (#4420, #4418)This release fixes a regression introduced by the previous release. When
metafile: truewas enabled in esbuild's JavaScript API, builds with build errors were incorrectly throwing an error about an empty JSON string instead of an object containing the build errors. -
Use define semantics for TypeScript parameter properties (#4421)
Parameter properties are a TypeScript-specific code generation feature that converts constructor parameters into class fields when they are prefixed by certain keywords. When
"useDefineForClassFields": trueis present intsconfig.json, the TypeScript compiler automatically generates class field declarations for parameter properties. Previously esbuild didn't do this, but esbuild will now do this starting with this release:// Original code class Foo { constructor(public x: number) {} } // Old output (with --loader=ts) class Foo { constructor(x) { this.x = x; } } // New output (with --loader=ts) class Foo { constructor(x) { this.x = x; } x; } -
Allow
es2025as a target intsconfig.json(#4432)TypeScript recently added
es2025as a compilation target, so esbuild now supports this in thetargetfield oftsconfig.jsonfiles, such as in the following configuration file:{ "compilerOptions": { "target": "ES2025" } }As a reminder, the only thing that esbuild uses this field for is determining whether or not to use legacy TypeScript behavior for class fields. You can read more in the documentation.
0.27.4
-
Fix a regression with CSS media queries (#4395, #4405, #4406)
Version 0.25.11 of esbuild introduced support for parsing media queries. This unintentionally introduced a regression with printing media queries that use the
<media-type> and <media-condition-without-or>grammar. Specifically, esbuild was failing to wrap anorclause with parentheses when inside<media-condition-without-or>. This release fixes the regression.Here is an example:
/* Original code */ @media only screen and ((min-width: 10px) or (min-height: 10px)) { a { color: red } } /* Old output (incorrect) */ @media only screen and (min-width: 10px) or (min-height: 10px) { a { color: red; } } /* New output (correct) */ @media only screen and ((min-width: 10px) or (min-height: 10px)) { a { color: red; } } -
Fix an edge case with the
injectfeature (#4407)This release fixes an edge case where esbuild's
injectfeature could not be used with arbitrary module namespace names exported using anexport {} fromstatement with bundling disabled and a target environment where arbitrary module namespace names is unsupported.With the fix, the following
injectfile:import jquery from 'jquery'; export { jquery as 'window.jQuery' };Can now always be rewritten as this without esbuild sometimes incorrectly generating an error:
export { default as 'window.jQuery' } from 'jquery'; -
Attempt to improve API handling of huge metafiles (#4329, #4415)
This release contains a few changes that attempt to improve the behavior of esbuild's JavaScript API with huge metafiles (esbuild's name for the build metadata, formatted as a JSON object). The JavaScript API is designed to return the metafile JSON as a JavaScript object in memory, which makes it easy to access from within a JavaScript-based plugin. Multiple people have encountered issues where this API breaks down with a pathologically-large metafile.
The primary issue is that V8 has an implementation-specific maximum string length, so using the
JSON.parseAPI with large enough strings is impossible. This release will now attempt to use a fallback JavaScript-based JSON parser that operates directly on the UTF8-encoded JSON bytes instead of usingJSON.parsewhen the JSON metafile is too big to fit in a JavaScript string. The new fallback path has not yet been heavily-tested. The metafile will also now be generated with whitespace removed if the bundle is significantly large, which will reduce the size of the metafile JSON slightly.However, hitting this case is potentially a sign that something else is wrong. Ideally you wouldn't be building something so enormous that the build metadata can't even fit inside a JavaScript string. You may want to consider optimizing your project, or breaking up your project into multiple parts that are built independently. Another option could potentially be to use esbuild's command-line API instead of its JavaScript API, which is more efficient (although of course then you can't use JavaScript plugins, so it may not be an option).
0.27.3
-
Preserve URL fragments in data URLs (#4370)
Consider the following HTML, CSS, and SVG:
-
index.html:<!DOCTYPE html> <html> <head><link rel="stylesheet" href="icons.css"></head> <body><div class="triangle"></div></body> </html> -
icons.css:.triangle { width: 10px; height: 10px; background: currentColor; clip-path: url(./triangle.svg#x); } -
triangle.svg:<svg xmlns="http://www.w3.org/2000/svg"> <defs> <clipPath id="x"> <path d="M0 0H10V10Z"/> </clipPath> </defs> </svg>
The CSS uses a URL fragment (the
#x) to reference theclipPathelement in the SVG file. Previously esbuild's CSS bundler didn't preserve the URL fragment when bundling the SVG using thedataurlloader, which broke the bundled CSS. With this release, esbuild will now preserve the URL fragment in the bundled CSS:/* icons.css */ .triangle { width: 10px; height: 10px; background: currentColor; clip-path: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><defs><clipPath id="x"><path d="M0 0H10V10Z"/></clipPath></defs></svg>#x'); } -
-
Parse and print CSS
@scoperules (#4322)This release includes dedicated support for parsing
@scoperules in CSS. These rules include optional "start" and "end" selector lists. One important consequence of this is that the local/global status of names in selector lists is now respected, which improves the correctness of esbuild's support for CSS modules. Minification of selectors inside@scoperules has also improved slightly.Here's an example:
/* Original code */ @scope (:global(.foo)) to (:local(.bar)) { .bar { color: red; } } /* Old output (with --loader=local-css --minify) */ @scope (:global(.foo)) to (:local(.bar)){.o{color:red}} /* New output (with --loader=local-css --minify) */ @scope(.foo)to (.o){.o{color:red}} -
Fix a minification bug with lowering of
for await(#4378, #4385)This release fixes a bug where the minifier would incorrectly strip the variable in the automatically-generated
catchclause of loweredfor awaitloops. The code that generated the loop previously failed to mark the internal variable references as used. -
Update the Go compiler from v1.25.5 to v1.25.7 (#4383, #4388)
This PR was contributed by @MikeWillCook.
2025
All esbuild versions published in the year 2025 (versions 0.25.0 through 0.27.2) can be found in CHANGELOG-2025.md.
2024
All esbuild versions published in the year 2024 (versions 0.19.12 through 0.24.2) can be found in CHANGELOG-2024.md.
2023
All esbuild versions published in the year 2023 (versions 0.16.13 through 0.19.11) can be found in CHANGELOG-2023.md.
2022
All esbuild versions published in the year 2022 (versions 0.14.11 through 0.16.12) can be found in CHANGELOG-2022.md.
2021
All esbuild versions published in the year 2021 (versions 0.8.29 through 0.14.10) can be found in CHANGELOG-2021.md.
2020
All esbuild versions published in the year 2020 (versions 0.3.0 through 0.8.28) can be found in CHANGELOG-2020.md.