Packages

@esbuild/linux-riscv64

0.28.2 · 8 Aug 2026MIT11.8M / weekRepositoryHomepagenpmAtom feed

Your version

113 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.

  1. 0.28.x · latest line
  2. 0.28.2

    8 Aug 2026
    • Fix tree shaking bug due to TypeScript import alias

      This release fixes a bug that could cause esbuild to incorrectly tree-shake imports that are used in a TypeScript type alias under certain circumstances. Affected code uses a TypeScript-specific import assignment and looks something like this:

      import Base from './dep.js';
      import Alias = Base.SomeType;
    • Fix CSS minification bug involving &

      This release fixes a bug where esbuild's CSS minifier incorrectly removed a & when it was unsafe to do so. Here is an example:

      /* Original code */
      .a .b {
        & .b:not(& .c) {
          color: red;
        }
      }
      
      /* Old output (with --minify) */
      .a .b{.b:not(& .c){color:red}}
      
      /* New output (with --minify) */
      .a .b{& .b:not(& .c){color:red}}

      This should match <span class="a"><span class="b"><span class="b">yes</span></span></span> but not <span class="a"><span class="b">no</span></span>. The old output incorrectly matched both.

    • Avoid overwriting input files without --allow-overwrite

      For example: esbuild input.js --outfile=input.js tells esbuild to overwrite input.js with the output of running esbuild on it. This was supposed to already be prevented by default, but it accidentally regressed in version 0.17.0 and apparently didn't have any test coverage. The error message was being printed but the input file was still being overwritten. Oops.

      This release puts the original behavior back. With this release, esbuild should now actually avoid overwriting input files unless --allow-overwrite is explicitly present. This is done by not writing out any files when a build error is encountered.

  3. 0.28.1

    11 Jun 2026
    • Security

      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's path.Clean() function, which only handles Unix-style / characters. HTTP requests with paths containing \ are no longer allowed.

    • Security

      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.org by default, but allows the NPM_CONFIG_REGISTRY environment variable to override this with a custom package registry. This change means that the esbuild executable served by NPM_CONFIG_REGISTRY must now match the expected content.

    • Avoid inlining using and await using declarations

      Previously esbuild's minifier sometimes incorrectly inlined using and await using declarations into subsequent uses of that declaration, which then fails to dispose of the resource correctly. This bug happened because inlining was done for let and const declarations by avoiding doing it for var declarations, 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()}
  4. 0.28.0

    2 Apr 2026
    • Add support for with { type: 'text' } imports

      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 text loader. Here's an example:

      import string from './example.txt' with { type: 'text' }
      console.log(string)
    • Add integrity checks to fallback download path

      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 npm command, and then with a HTTP request to registry.npmjs.org as 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 esbuild package. 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:

      You can read the Go 1.26 release notes for more information.

  5. 0.27.x
  6. 0.27.7

    2 Apr 2026
    • Fix lowering of define semantics for TypeScript parameter properties

      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);
        }
      }
  7. 0.27.6

    2 Apr 2026
  8. 0.27.5

    2 Apr 2026
    • 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

    • Fix a regression when metafile is enabled (#4420, #4418)

      This release fixes a regression introduced by the previous release. When metafile: true was 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

      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": true is present in tsconfig.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;
      }
  9. 0.27.4

    12 Mar 2026
    • 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 an or clause 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 inject feature

      This release fixes an edge case where esbuild's inject feature could not be used with arbitrary module namespace names exported using an export {} from statement with bundling disabled and a target environment where arbitrary module namespace names is unsupported.

      With the fix, the following inject file:

      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.parse API 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 using JSON.parse when 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).

  10. 0.27.3

    5 Feb 2026
    • Preserve URL fragments in data URLs

      Consider the following HTML, CSS, and SVG:

      The CSS uses a URL fragment (the #x) to reference the clipPath element in the SVG file. Previously esbuild's CSS bundler didn't preserve the URL fragment when bundling the SVG using the dataurl loader, 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 @scope rules

      This release includes dedicated support for parsing @scope rules 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 @scope rules 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 catch clause of lowered for await loops. The code that generated the loop previously failed to mark the internal variable references as used.

  11. 0.27.2

    17 Dec 2025
    • Allow import path specifiers starting with #/

      Previously the specification for package.json disallowed import path specifiers starting with #/, but this restriction has recently been relaxed and support for it is being added across the JavaScript ecosystem. One use case is using it for a wildcard pattern such as mapping #/* to ./src/* (previously you had to use another character such as #_* instead, which was more confusing). There is some more context in nodejs/node#49182.

      This change was contributed

    • Automatically add the -webkit-mask prefix (#4357, #4358)

      This release automatically adds the -webkit- vendor prefix for the mask CSS shorthand property:

      /* Original code */
      main {
        mask: url(x.png) center/5rem no-repeat
      }
      
      /* Old output (with --target=chrome110) */
      main {
        mask: url(x.png) center/5rem no-repeat;
      }
      
      /* New output (with --target=chrome110) */
      main {
        -webkit-mask: url(x.png) center/5rem no-repeat;
        mask: url(x.png) center/5rem no-repeat;
      }

      This change was contributed

    • Additional minification of switch statements (#4176, #4359)

      This release contains additional minification patterns for reducing switch statements. Here is an example:

      // Original code
      switch (x) {
        case 0:
          foo()
          break
        case 1:
        default:
          bar()
      }
      
      // Old output (with --minify)
      switch(x){case 0:foo();break;case 1:default:bar()}
      
      // New output (with --minify)
      x===0?foo():bar();
  12. 0.27.1

    3 Dec 2025
    • Fix bundler bug with var nested inside if

      This release fixes a bug with the bundler that happens when importing an ES module using require (which causes it to be wrapped) and there's a top-level var inside an if statement without being wrapped in a { ... } block (and a few other conditions). The bundling transform needed to hoist these var declarations outside of the lazy ES module wrapper for correctness. See the issue for details.

    • Fix minifier bug with for inside try inside label

      This fixes an old regression from version v0.21.4. Some code was introduced to move the label inside the try statement to address a problem with transforming labeled for await loops to avoid the await (the transformation involves converting the for await loop into a for loop and wrapping it in a try statement). However, it introduces problems for cross-compiled JVM code that uses all three of these features heavily. This release restricts this transform to only apply to for loops that esbuild itself generates internally as part of the for await transform. Here is an example of some affected code:

      // Original code
      d: {
        e: {
          try {
            while (1) { break d }
          } catch { break e; }
        }
      }
      
      // Old output (with --minify)
      a:try{e:for(;;)break a}catch{break e}
      
      // New output (with --minify)
      a:e:try{for(;;)break a}catch{break e}
    • Inline IIFEs containing a single expression

      Previously inlining of IIFEs (immediately-invoked function expressions) only worked if the body contained a single return statement. Now it should also work if the body contains a single expression statement instead:

      // Original code
      const foo = () => {
        const cb = () => {
          console.log(x())
        }
        return cb()
      }
      
      // Old output (with --minify)
      const foo=()=>(()=>{console.log(x())})();
      
      // New output (with --minify)
      const foo=()=>{console.log(x())};
  13. 0.27.0

    9 Nov 2025
    • Use Uint8Array.fromBase64 if available

      With this release, esbuild's binary loader will now use the new Uint8Array.fromBase64 function unless it's unavailable in the configured target environment. If it's unavailable, esbuild's previous code for this will be used as a fallback. Note that this means you may now need to specify target when using this feature with Node (for example --target=node22) unless you're using Node v25+.

    • Update the Go compiler from v1.23.12 to v1.25.4 (#4208, #4311)

      This raises the operating system requirements for running esbuild:

  14. 0.26.x
  15. 0.26.0

    9 Nov 2025
    • Enable trusted publishing

      GitHub and npm are recommending that maintainers for packages such as esbuild switch to trusted publishing. With this release, a VM on GitHub will now build and publish all of esbuild's packages to npm instead of me. In theory.

      Unfortunately there isn't really a way to test that this works other than to do it live. So this release is that live test. Hopefully this release is uneventful and is exactly the same as the previous one (well, except for the green provenance attestation checkmark on npm that happens with trusted publishing).

  16. 0.25.x
  17. 0.25.12

    1 Nov 2025
    • Fix a minification regression with CSS media queries

      The previous release introduced support for parsing media queries which unintentionally introduced a regression with the removal of duplicate media rules during minification. Specifically the grammar for @media <media-type> and <media-condition-without-or> { ... } was missing an equality check for the <media-condition-without-or> part, so rules with different suffix clauses in this position would incorrectly compare equal and be deduplicated. This release fixes the regression.

    • Update the list of known JavaScript globals

      This release updates esbuild's internal list of known JavaScript globals. These are globals that are known to not have side-effects when the property is accessed. For example, accessing the global Array property is considered to be side-effect free but accessing the global scrollY property can trigger a layout, which is a side-effect. This is used by esbuild's tree-shaking to safely remove unused code that is known to be side-effect free. This update adds the following global properties:

      From ES2017:

      From ES2020:

      From ES2021:

      From ES2025:

      Note that this does not indicate that constructing any of these objects is side-effect free, just that accessing the identifier is side-effect free. For example, this now allows esbuild to tree-shake classes that extend from Iterator:

      // This can now be tree-shaken by esbuild:
      class ExampleIterator extends Iterator {}
    • Add support for the new @view-transition CSS rule

      With this release, esbuild now has improved support for pretty-printing and minifying the new @view-transition rule (which esbuild was previously unaware of):

      /* Original code */
      @view-transition {
        navigation: auto;
        types: check;
      }
      
      /* Old output */
      @view-transition { navigation: auto; types: check; }
      
      /* New output */
      @view-transition {
        navigation: auto;
        types: check;
      }

      The new view transition feature provides a mechanism for creating animated transitions between documents in a multi-page app. You can read more about view transition rules here.

      This change was contributed

  18. 0.25.11

    15 Oct 2025
    • Add support for with { type: 'bytes' } imports

      The import bytes proposal has reached stage 2.7 in the TC39 process, which means that although it isn't quite recommended for implementation, it's generally approved and ready for validation. Furthermore it has already been implemented by Deno and Webpack. So with this release, esbuild will also add support for this. It behaves exactly the same as esbuild's existing binary loader. Here's an example:

      import data from './image.png' with { type: 'bytes' }
      const view = new DataView(data.buffer, 0, 24)
      const width = view.getInt32(16)
      const height = view.getInt32(20)
      console.log('size:', width + '\xD7' + height)
    • Lower CSS media query range syntax (#3748, #4293)

      With this release, esbuild will now transform CSS media query range syntax into equivalent syntax using min-/max- prefixes for older browsers. For example, the following CSS:

      @media (640px <= width <= 960px) {
        main {
          display: flex;
        }
      }

      will be transformed like this with a target such as --target=chrome100 (or more specifically with --supported:media-range=false if desired):

      @media (min-width: 640px) and (max-width: 960px) {
        main {
          display: flex;
        }
      }
  19. 0.25.10

    17 Sep 2025
    • Fix a panic in a minification edge case

      This release fixes a panic due to a null pointer that could happen when esbuild inlines a doubly-nested identity function and the final result is empty. It was fixed by emitting the value undefined in this case, which avoids the panic. This case must be rare since it hasn't come up until now. Here is an example of code that previously triggered the panic (which only happened when minifying):

      function identity(x) { return x }
      identity({ y: identity(123) })
    • Fix @supports nested inside pseudo-element

      When transforming nested CSS to non-nested CSS, esbuild is supposed to filter out pseudo-elements such as ::placeholder for correctness. The CSS nesting specification says the following:

      The nesting selector cannot represent pseudo-elements (identical to the behavior of the ':is()' pseudo-class). We’d like to relax this restriction, but need to do so simultaneously for both ':is()' and '&', since they’re intentionally built on the same underlying mechanisms.

      However, it seems like this behavior is different for nested at-rules such as @supports, which do work with pseudo-elements. So this release modifies esbuild's behavior to now take that into account:

      /* Original code */
      ::placeholder {
        color: red;
        body & { color: green }
        @supports (color: blue) { color: blue }
      }
      
      /* Old output (with --supported:nesting=false) */
      ::placeholder {
        color: red;
      }
      body :is() {
        color: green;
      }
      @supports (color: blue) {
         {
          color: blue;
        }
      }
      
      /* New output (with --supported:nesting=false) */
      ::placeholder {
        color: red;
      }
      body :is() {
        color: green;
      }
      @supports (color: blue) {
        ::placeholder {
          color: blue;
        }
      }
  20. 0.25.9

    12 Aug 2025
    • Better support building projects that use Yarn on Windows (#3131, #3663)

      With this release, you can now use esbuild to bundle projects that use Yarn Plug'n'Play on Windows on drives other than the C: drive. The problem was as follows:

      Yarn works around this edge case by pretending Windows-style paths beginning with C:\ are actually Unix-style paths beginning with /C:/, so the ../.. path segments are able to navigate across drives inside Yarn's implementation. This was broken for a long time in esbuild but I finally got access to a Windows machine and was able to debug and fix this edge case. So you should now be able to bundle these projects with esbuild.

    • Preserve parentheses around function expressions

      The V8 JavaScript VM uses parentheses around function expressions as an optimization hint to immediately compile the function. Otherwise the function would be lazily-compiled, which has additional overhead if that function is always called immediately as lazy compilation involves parsing the function twice. You can read V8's blog post about this for more details.

      Previously esbuild did not represent parentheses around functions in the AST so they were lost during compilation. With this change, esbuild will now preserve parentheses around function expressions when they are present in the original source code. This means these optimization hints will not be lost when bundling with esbuild. In addition, esbuild will now automatically add this optimization hint to immediately-invoked function expressions. Here's an example:

      // Original code
      const fn0 = () => 0
      const fn1 = (() => 1)
      console.log(fn0, function() { return fn1() }())
      
      // Old output
      const fn0 = () => 0;
      const fn1 = () => 1;
      console.log(fn0, function() {
        return fn1();
      }());
      
      // New output
      const fn0 = () => 0;
      const fn1 = (() => 1);
      console.log(fn0, (function() {
        return fn1();
      })());

      Note that you do not want to wrap all function expressions in parentheses. This optimization hint should only be used for functions that are called on initial load. Using this hint for functions that are not called on initial load will unnecessarily delay the initial load. Again, see V8's blog post linked above for details.

    • Update Go from 1.23.10 to 1.23.12 (#4257, #4258)

      This should have no effect on existing code as this version change does not change Go's operating system support. It may remove certain false positive reports (specifically CVE-2025-4674 and CVE-2025-47907) from vulnerability scanners that only detect which version of the Go compiler esbuild uses.

  21. 0.25.8

    19 Jul 2025
    • Fix another TypeScript parsing edge case

      This fixes a regression with a change in the previous release that tries to more accurately parse TypeScript arrow functions inside the ?: operator. The regression specifically involves parsing an arrow function containing a #private identifier inside the middle of a ?: ternary operator inside a class body. This was fixed by propagating private identifier state into the parser clone used to speculatively parse the arrow function body. Here is an example of some affected code:

      class CachedDict {
        #has = (a: string) => dict.has(a);
        has = window
          ? (word: string): boolean => this.#has(word)
          : this.#has;
      }
    • Fix a regression with the parsing of source phase imports

      The change in the previous release to parse source phase imports failed to properly handle the following cases:

      import source from 'bar'
      import source from from 'bar'
      import source type foo from 'bar'

      Parsing for these cases should now be fixed. The first case was incorrectly treated as a syntax error because esbuild was expecting the second case. And the last case was previously allowed but is now forbidden. TypeScript hasn't added this feature yet so it remains to be seen whether the last case will be allowed, but it's safer to disallow it for now. At least Babel doesn't allow the last case when parsing TypeScript, and Babel was involved with the source phase import specification.

  22. 0.25.7

    18 Jul 2025
    • Parse and print JavaScript imports with an explicit phase

      This release adds basic syntax support for the defer and source import phases in JavaScript:

      This change only adds support for this syntax. These imports cannot currently be bundled by esbuild. To use these new features with esbuild's bundler, the imported paths must be external to the bundle and the output format must be set to esm.

    • Support optionally emitting absolute paths instead of relative paths (#338, #2082, #3023)

      This release introduces the --abs-paths= feature which takes a comma-separated list of situations where esbuild should use absolute paths instead of relative paths. There are currently three supported situations: code (comments and string literals), log (log message text and location info), and metafile (the JSON build metadata).

      Using absolute paths instead of relative paths is not the default behavior because it means that the build results are no longer machine-independent (which means builds are no longer reproducible). Absolute paths can be useful when used with certain terminal emulators that allow you to click on absolute paths in the terminal text and/or when esbuild is being automatically invoked from several different directories within the same script.

    • Fix a TypeScript parsing edge case

      This release fixes an edge case with parsing an arrow function in TypeScript with a return type that's in the middle of a ?: ternary operator. For example:

      x = a ? (b) : c => d;
      y = a ? (b) : c => d : e;

      The : token in the value assigned to x pairs with the ? token, so it's not the start of a return type annotation. However, the first : token in the value assigned to y is the start of a return type annotation because after parsing the arrow function body, it turns out there's another : token that can be used to pair with the ? token. This case is notable as it's the first TypeScript edge case that esbuild has needed a backtracking parser to parse. It has been addressed by a quick hack (cloning the whole parser) as it's a rare edge case and esbuild doesn't otherwise need a backtracking parser. Hopefully this is sufficient and doesn't cause any issues.

  23. 0.25.6

    7 Jul 2025
    • Fix a memory leak when cancel() is used on a build context

      Calling rebuild() followed by cancel() in rapid succession could previously leak memory. The bundler uses a producer/consumer model internally, and the resource leak was caused by the consumer being termianted while there were still remaining unreceived results from a producer. To avoid the leak, the consumer now waits for all producers to finish before terminating.

    • Support empty :is() and :where() syntax in CSS

      Previously using these selectors with esbuild would generate a warning. That warning has been removed in this release for these cases.

    • Improve tree-shaking of try statements in dead code

      With this release, esbuild will now remove certain try statements if esbuild considers them to be within dead code (i.e. code that is known to not ever be evaluated). For example:

      // Original code
      return 'foo'
      try { return 'bar' } catch {}
      
      // Old output (with --minify)
      return"foo";try{return"bar"}catch{}
      
      // New output (with --minify)
      return"foo";
  24. 0.25.5

    27 May 2025
    • Fix a regression with browser in package.json

      The fix to #4144 in version 0.25.3 introduced a regression that caused browser overrides specified in package.json to fail to override relative path names that end in a trailing slash. That behavior change affected the axios@0.30.0 package. This regression has been fixed, and now has test coverage.

    • Add support for certain keywords as TypeScript tuple labels

      Previously esbuild could incorrectly fail to parse certain keywords as TypeScript tuple labels that are parsed by the official TypeScript compiler if they were followed by a ? modifier. These labels included function, import, infer, new, readonly, and typeof. With this release, these keywords will now be parsed correctly. Here's an example of some affected code:

      type Foo = [
        value: any,
        readonly?: boolean, // This is now parsed correctly
      ]
    • Add CSS prefixes for the stretch sizing value

      This release adds support for prefixing CSS declarations such as div { width: stretch }. That CSS is now transformed into this depending on what the --target= setting includes:

      div {
        width: -webkit-fill-available;
        width: -moz-available;
        width: stretch;
      }
  25. 0.25.4

    6 May 2025
    • Add simple support for CORS to esbuild's development server

      Starting with version 0.25.0, esbuild's development server is no longer configured to serve cross-origin requests. This was a deliberate change to prevent any website you visit from accessing your running esbuild development server. However, this change prevented (by design) certain use cases such as "debugging in production" by having your production website load code from localhost where the esbuild development server is running.

      To enable this use case, esbuild is adding a feature to allow Cross-Origin Resource Sharing (a.k.a. CORS) for simple requests. Specifically, passing your origin to the new cors option will now set the Access-Control-Allow-Origin response header when the request has a matching Origin header. Note that this currently only works for requests that don't send a preflight OPTIONS request, as esbuild's development server doesn't currently support OPTIONS requests.

      Some examples:

      The special origin * can be used to allow any origin to access esbuild's development server. Note that this means any website you visit will be able to read everything served by esbuild.

    • Pass through invalid URLs in source maps unmodified

      This fixes a regression in version 0.25.0 where sources in source maps that form invalid URLs were not being passed through to the output. Version 0.25.0 changed the interpretation of sources from file paths to URLs, which means that URL parsing can now fail. Previously URLs that couldn't be parsed were replaced with the empty string. With this release, invalid URLs in sources should now be passed through unmodified.

    • Handle exports named __proto__ in ES modules (#4162, #4163)

      In JavaScript, the special property name __proto__ sets the prototype when used inside an object literal. Previously esbuild's ESM-to-CommonJS conversion didn't special-case the property name of exports named __proto__ so the exported getter accidentally became the prototype of the object literal. It's unclear what this affects, if anything, but it's better practice to avoid this by using a computed property name in this case.

      This fix was contributed

  26. 0.25.3

    23 Apr 2025
    • Fix lowered async arrow functions before super() (#4141, #4142)

      This change makes it possible to call an async arrow function in a constructor before calling super() when targeting environments without async support, as long as the function body doesn't reference this. Here's an example (notice the change from this to null):

      // Original code
      class Foo extends Object {
        constructor() {
          (async () => await foo())()
          super()
        }
      }
      
      // Old output (with --target=es2016)
      class Foo extends Object {
        constructor() {
          (() => __async(this, null, function* () {
            return yield foo();
          }))();
          super();
        }
      }
      
      // New output (with --target=es2016)
      class Foo extends Object {
        constructor() {
          (() => __async(null, null, function* () {
            return yield foo();
          }))();
          super();
        }
      }

      Some background: Arrow functions with the async keyword are transformed into generator functions for older language targets such as --target=es2016. Since arrow functions capture this, the generated code forwards this into the body of the generator function. However, JavaScript class syntax forbids using this in a constructor before calling super(), and this forwarding was problematic since previously happened even when the function body doesn't use this. Starting with this release, esbuild will now only forward this if it's used within the function body.

      This fix was contributed

    • Fix memory leak with --watch=true (#4131, #4132)

      This release fixes a memory leak with esbuild when --watch=true is used instead of --watch. Previously using --watch=true caused esbuild to continue to use more and more memory for every rebuild, but --watch=true should now behave like --watch and not leak memory.

      This bug happened because esbuild disables the garbage collector when it's not run as a long-lived process for extra speed, but esbuild's checks for which arguments cause esbuild to be a long-lived process weren't updated for the new --watch=true style of boolean command-line flags. This has been an issue since this boolean flag syntax was added in version 0.14.24 in 2022. These checks are unfortunately separate from the regular argument parser because of how esbuild's internals are organized (the command-line interface is exposed as a separate Go API so you can build your own custom esbuild CLI).

      This fix was contributed

    • More concise output for repeated legal comments

      Some libraries have many files and also use the same legal comment text in all files. Previously esbuild would copy each legal comment to the output file. Starting with this release, legal comments duplicated across separate files will now be grouped in the output file by unique comment content.

  27. 0.25.2

    30 Mar 2025
    • Support flags in regular expressions for the API

      The JavaScript plugin API for esbuild takes JavaScript regular expression objects for the filter option. Internally these are translated into Go regular expressions. However, this translation previously ignored the flags property of the regular expression. With this release, esbuild will now translate JavaScript regular expression flags into Go regular expression flags. Specifically the JavaScript regular expression /\.[jt]sx?$/i is turned into the Go regular expression `(?i)\.[jt]sx?$` internally inside of esbuild's API. This should make it possible to use JavaScript regular expressions with the i flag. Note that JavaScript and Go don't support all of the same regular expression features, so this mapping is only approximate.

    • Fix node-specific annotations for string literal export names

      When node instantiates a CommonJS module, it scans the AST to look for names to expose via ESM named exports. This is a heuristic that looks for certain patterns such as exports.NAME = ... or module.exports = { ... }. This behavior is used by esbuild to "annotate" CommonJS code that was converted from ESM with the original ESM export names. For example, when converting the file export let foo, bar from ESM to CommonJS, esbuild appends this to the end of the file:

      // Annotate the CommonJS export names for ESM import in node:
      0 && (module.exports = {
        bar,
        foo
      });

      However, this feature previously didn't work correctly for export names that are not valid identifiers, which can be constructed using string literal export names. The generated code contained a syntax error. That problem is fixed in this release:

      // Original code
      let foo
      export { foo as "foo!" }
      
      // Old output (with --format=cjs --platform=node)
      ...
      0 && (module.exports = {
        "foo!"
      });
      
      // New output (with --format=cjs --platform=node)
      ...
      0 && (module.exports = {
        "foo!": null
      });
    • Basic support for index source maps (#3439, #4109)

      The source map specification has an optional mode called index source maps that makes it easier for tools to create an aggregate JavaScript file by concatenating many smaller JavaScript files with source maps, and then generate an aggregate source map by simply providing the original source maps along with some offset information. My understanding is that this is rarely used in practice. I'm only aware of two uses of it in the wild: ClojureScript and Turbopack.

      This release provides basic support for indexed source maps. However, the implementation has not been tested on a real app (just on very simple test input). If you are using index source maps in a real app, please try this out and report back if anything isn't working for you.

      Note that this is also not a complete implementation. For example, index source maps technically allows nesting source maps to an arbitrary depth, while esbuild's implementation in this release only supports a single level of nesting. It's unclear whether supporting more than one level of nesting is important or not given the lack of available test cases.

      This feature was contributed

  28. 0.25.1

    10 Mar 2025
    • Fix incorrect paths in inline source maps (#4070, #4075, #4105)

      This fixes a regression from version 0.25.0 where esbuild didn't correctly resolve relative paths contained within source maps in inline sourceMappingURL data URLs. The paths were incorrectly being passed through as-is instead of being resolved relative to the source file containing the sourceMappingURL comment, which was due to the data URL not being a file URL. This regression has been fixed, and this case now has test coverage.

    • Fix invalid generated source maps (#4080, #4082, #4104, #4107)

      This release fixes a regression from version 0.24.1 that could cause esbuild to generate invalid source maps. Specifically under certain conditions, esbuild could generate a mapping with an out-of-bounds source index. It was introduced by code that attempted to improve esbuild's handling of "null" entries in source maps (i.e. mappings with a generated position but no original position). This regression has been fixed.

      This fix was contributed

    • Fix a regression with non-file source map paths

      The format of paths in source maps that aren't in the file namespace was unintentionally changed in version 0.25.0. Path namespaces is an esbuild-specific concept that is optionally available for plugins to use to distinguish paths from file paths and from paths meant for other plugins. Previously the namespace was prepended to the path joined with a : character, but version 0.25.0 unintentionally failed to prepend the namespace. The previous behavior has been restored.

  29. 0.25.0

    8 Feb 2025
    • Security

      Restrict access to esbuild's development server (GHSA-67mh-4wv8-2f99)

      This change addresses esbuild's first security vulnerability report. Previously esbuild set the Access-Control-Allow-Origin header to * to allow esbuild's development server to be flexible in how it's used for development. However, this allows the websites you visit to make HTTP requests to esbuild's local development server, which gives read-only access to your source code if the website were to fetch your source code's specific URL. You can read more information in the report.

      Starting with this release, CORS will now be disabled, and requests will now be denied if the host does not match the one provided to --serve=. The default host is 0.0.0.0, which refers to all of the IP addresses that represent the local machine (e.g. both 127.0.0.1 and 192.168.0.1). If you want to customize anything about esbuild's development server, you can put a proxy in front of esbuild and modify the incoming and/or outgoing requests.

      In addition, the serve() API call has been changed to return an array of hosts instead of a single host string. This makes it possible to determine all of the hosts that esbuild's development server will accept.

    • Delete output files when a build fails in watch mode

      It has been requested for esbuild to delete files when a build fails in watch mode. Previously esbuild left the old files in place, which could cause people to not immediately realize that the most recent build failed. With this release, esbuild will now delete all output files if a rebuild fails. Fixing the build error and triggering another rebuild will restore all output files again.

    • Fix correctness issues with the CSS nesting transform (#3620, #3877, #3933, #3997, #4005, #4037, #4038)

      This release fixes the following problems:

  30. 0.24.x
  31. 0.24.2

    20 Dec 2024
    • Fix regression with --define and import.meta (#4010, #4012, #4013)

      The previous change in version 0.24.1 to use a more expression-like parser for define values to allow quoted property names introduced a regression that removed the ability to use --define:import.meta=.... Even though import is normally a keyword that can't be used as an identifier, ES modules special-case the import.meta expression to behave like an identifier anyway. This change fixes the regression.

      This fix was contributed

  32. 0.24.1

    20 Dec 2024
    • Allow es2024 as a target in tsconfig.json

      TypeScript recently added es2024 as a compilation target, so esbuild now supports this in the target field of tsconfig.json files, such as in the following configuration file:

      {
        "compilerOptions": {
          "target": "ES2024"
        }
      }

      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.

      This fix was contributed

    • Allow automatic semicolon insertion after get/set

      This change fixes a grammar bug in the parser that incorrectly treated the following code as a syntax error:

      class Foo {
        get
        *x() {}
        set
        *y() {}
      }

      The above code will be considered valid starting with this release. This change to esbuild follows a similar change to TypeScript which will allow this syntax starting with TypeScript 5.7.

    • Allow quoted property names in --define and --pure

      The define and pure API options now accept identifier expressions containing quoted property names. Previously all identifiers in the identifier expression had to be bare identifiers. This change now makes --define and --pure consistent with --global-name, which already supported quoted property names. For example, the following is now possible:

      // The following code now transforms to "return true;\n"
      console.log(esbuild.transformSync(
        `return process.env['SOME-TEST-VAR']`,
        { define: { 'process.env["SOME-TEST-VAR"]': 'true' } },
      ))

      Note that if you're passing values like this on the command line using esbuild's --define flag, then you'll need to know how to escape quote characters for your shell. You may find esbuild's JavaScript API more ergonomic and portable than writing shell code.

  33. 0.24.0

    22 Sep 2024
    • Removed

      Drop support for older platforms

      This release drops support for the following operating system:

      This is because the Go programming language dropped support for this operating system version in Go 1.23, and this release updates esbuild from Go 1.22 to Go 1.23. Go 1.23 now requires macOS 11 Big Sur or later.

      Note that this only affects the binary esbuild executables that are published to the esbuild npm package. It's still possible to compile esbuild's source code for these older operating systems. If you need to, you can compile esbuild for yourself using an older version of the Go compiler (before Go version 1.23). That might look something like this:

      git clone https://github.com/evanw/esbuild.git
      cd esbuild
      go build ./cmd/esbuild
      ./esbuild --version
    • Fix class field decorators in TypeScript if useDefineForClassFields is false

      Setting the useDefineForClassFields flag to false in tsconfig.json means class fields use the legacy TypeScript behavior instead of the standard JavaScript behavior. Specifically they use assign semantics instead of define semantics (e.g. setters are triggered) and fields without an initializer are not initialized at all. However, when this legacy behavior is combined with standard JavaScript decorators, TypeScript switches to always initializing all fields, even those without initializers. Previously esbuild incorrectly continued to omit field initializers for this edge case. These field initializers in this case should now be emitted starting with this release.

    • Avoid incorrect cycle warning with tsconfig.json multiple inheritance

      TypeScript 5.0 introduced multiple inheritance for tsconfig.json files where extends can be an array of file paths. Previously esbuild would incorrectly treat files encountered more than once when processing separate subtrees of the multiple inheritance hierarchy as an inheritance cycle. With this release, tsconfig.json files containing this edge case should work correctly without generating a warning.

  34. 0.23.x
  35. 0.23.1

    16 Aug 2024
    • Allow using the node: import prefix with es* targets

      The node: prefix on imports is an alternate way to import built-in node modules. For example, import fs from "fs" can also be written import fs from "node:fs". This only works with certain newer versions of node, so esbuild removes it when you target older versions of node such as with --target=node14 so that your code still works. With the way esbuild's platform-specific feature compatibility table works, this was added by saying that only newer versions of node support this feature. However, that means that a target such as --target=node18,es2022 removes the node: prefix because none of the es* targets are known to support this feature. This release adds the support for the node: flag to esbuild's internal compatibility table for es* to allow you to use compound targets like this:

      // Original code
      import fs from 'node:fs'
      fs.open
      
      // Old output (with --bundle --format=esm --platform=node --target=node18,es2022)
      import fs from "fs";
      fs.open;
      
      // New output (with --bundle --format=esm --platform=node --target=node18,es2022)
      import fs from "node:fs";
      fs.open;
    • Fix a panic when using the CLI with invalid build flags if --analyze is present

      Previously esbuild's CLI could crash if it was invoked with flags that aren't valid for a "build" API call and the --analyze flag is present. This was caused by esbuild's internals attempting to add a Go plugin (which is how --analyze is implemented) to a null build object. The panic has been fixed in this release.

    • Fix incorrect location of certain error messages

      This release fixes a regression that caused certain errors relating to variable declarations to be reported at an incorrect location. The regression was introduced in version 0.18.7 of esbuild.

  36. 0.23.0

    2 Jul 2024
    • Revert the recent change to avoid bundling dependencies for node

      This release reverts the recent change in version 0.22.0 that made --packages=external the default behavior with --platform=node. The default is now back to --packages=bundle.

      I've just been made aware that Amazon doesn't pin their dependencies in their "AWS CDK" product, which means that whenever esbuild publishes a new release, many people (potentially everyone?) using their SDK around the world instantly starts using it without Amazon checking that it works first. This change in version 0.22.0 happened to break their SDK. I'm amazed that things haven't broken before this point. This revert attempts to avoid these problems for Amazon's customers. Hopefully Amazon will pin their dependencies in the future.

      In addition, this is probably a sign that esbuild is used widely enough that it now needs to switch to a more complicated release model. I may have esbuild use a beta channel model for further development.

    • Fix preserving collapsed JSX whitespace

      When transformed, certain whitespace inside JSX elements is ignored completely if it collapses to an empty string. However, the whitespace should only be ignored if the JSX is being transformed, not if it's being preserved. This release fixes a bug where esbuild was previously incorrectly ignoring collapsed whitespace with --jsx=preserve. Here is an example:

      // Original code
      <Foo>
        <Bar />
      </Foo>
      
      // Old output (with --jsx=preserve)
      <Foo><Bar /></Foo>;
      
      // New output (with --jsx=preserve)
      <Foo>
        <Bar />
      </Foo>;
  37. 0.22.x
  38. 0.22.0

    30 Jun 2024
    • Removed

      Drop support for older platforms

      This release drops support for the following operating systems:

      This is because the Go programming language dropped support for these operating system versions in Go 1.21, and this release updates esbuild from Go 1.20 to Go 1.22.

      Note that this only affects the binary esbuild executables that are published to the esbuild npm package. It's still possible to compile esbuild's source code for these older operating systems. If you need to, you can compile esbuild for yourself using an older version of the Go compiler (before Go version 1.21). That might look something like this:

      git clone https://github.com/evanw/esbuild.git
      cd esbuild
      go build ./cmd/esbuild
      ./esbuild.exe --version

      In addition, this release increases the minimum required node version for esbuild's JavaScript API from node 12 to node 18. Node 18 is the oldest version of node that is still being supported (see node's release schedule for more information). This increase is because of an incompatibility between the JavaScript that the Go compiler generates for the esbuild-wasm package and versions of node before node 17.4 (specifically the crypto.getRandomValues function).

    • Omit packages from bundles by default when targeting node (#1874, #2830, #2846, #2915, #3145, #3294, #3323, #3582, #3809, #3815)

      This breaking change is an experiment. People are commonly confused when using esbuild to bundle code for node (i.e. for --platform=node) because some packages may not be intended for bundlers, and may use node-specific features that don't work with a bundler. Even though esbuild's "getting started" instructions say to use --packages=external to work around this problem, many people don't read the documentation and don't do this, and are then confused when it doesn't work. So arguably this is a bad default behavior for esbuild to have if people keep tripping over this.

      With this release, esbuild will now omit packages from the bundle by default when the platform is node (i.e. the previous behavior of --packages=external is now the default in this case). Note that your dependencies must now be present on the file system when your bundle is run. If you don't want this behavior, you can do --packages=bundle to allow packages to be included in the bundle (i.e. the previous default behavior). Note that --packages=bundle doesn't mean all packages are bundled, just that packages are allowed to be bundled. You can still exclude individual packages from the bundle using --external: even when --packages=bundle is present.

      The --packages= setting considers all import paths that "look like" package imports in the original source code to be package imports. Specifically import paths that don't start with a path segment of / or . or .. are considered to be package imports. The only two exceptions to this rule are subpath imports (which start with a # character) and TypeScript path remappings via paths and/or baseUrl in tsconfig.json (which are applied first).

    • Update await using behavior to match TypeScript

      TypeScript 5.5 subtly changes the way await using behaves. This release updates esbuild to match these changes in TypeScript. You can read more about these changes in microsoft/TypeScript#58624.

  39. 0.21.x
  40. 0.21.5

    9 Jun 2024
    • Fix Symbol.metadata on classes without a class decorator

      This release fixes a bug with esbuild's support for the decorator metadata proposal. Previously esbuild only added the Symbol.metadata property to decorated classes if there was a decorator on the class element itself. However, the proposal says that the Symbol.metadata property should be present on all classes that have any decorators at all, not just those with a decorator on the class element itself.

    • Allow unknown import attributes to be used with the copy loader

      Import attributes (the with keyword on import statements) are allowed to alter how that path is loaded. For example, esbuild cannot assume that it knows how to load ./bagel.js as type bagel:

      // This is an error with "--bundle" without also using "--external:./bagel.js"
      import tasty from "./bagel.js" with { type: "bagel" }

      Because of that, bundling this code with esbuild is an error unless the file ./bagel.js is external to the bundle (such as with --bundle --external:./bagel.js).

      However, there is an additional case where it's ok for esbuild to allow this: if the file is loaded using the copy loader. That's because the copy loader behaves similarly to --external in that the file is left external to the bundle. The difference is that the copy loader copies the file into the output folder and rewrites the import path while --external doesn't. That means the following will now work with the copy loader (such as with --bundle --loader:.bagel=copy):

      // This is no longer an error with "--bundle" and "--loader:.bagel=copy"
      import tasty from "./tasty.bagel" with { type: "bagel" }
    • Support import attributes with glob-style imports

      This release adds support for import attributes (the with option) to glob-style imports (dynamic imports with certain string literal patterns as paths). These imports previously didn't support import attributes due to an oversight. So code like this will now work correctly:

      async function loadLocale(locale: string): Locale {
        const data = await import(`./locales/${locale}.data`, { with: { type: 'json' } })
        return unpackLocale(locale, data)
      }

      Previously this didn't work even though esbuild normally supports forcing the JSON loader using an import attribute. Attempting to do this used to result in the following error:

      ✘ [ERROR] No loader is configured for ".data" files: locales/en-US.data
      
          example.ts:2:28:
            2 │   const data = await import(`./locales/${locale}.data`, { with: { type: 'json' } })
              ╵                             ~~~~~~~~~~~~~~~~~~~~~~~~~~

      In addition, this change means plugins can now access the contents of with for glob-style imports.

  41. 0.21.4

    25 May 2024
    • Update support for import assertions and import attributes in node

      Import assertions (the assert keyword) have been removed from node starting in v22.0.0. So esbuild will now strip them and generate a warning with --target=node22 or above:

      ▲ [WARNING] The "assert" keyword is not supported in the configured target environment ("node22") [assert-to-with]
      
          example.mjs:1:40:
            1 │ import json from "esbuild/package.json" assert { type: "json" }
              │                                         ~~~~~~
              ╵                                         with
      
        Did you mean to use "with" instead of "assert"?

      Import attributes (the with keyword) have been backported to node 18 starting in v18.20.0. So esbuild will no longer strip them with --target=node18.N if N is 20 or greater.

    • Fix for await transform when a label is present

      This release fixes a bug where the for await transform, which wraps the loop in a try statement, previously failed to also move the loop's label into the try statement. This bug only affects code that uses both of these features in combination. Here's an example of some affected code:

      // Original code
      async function test() {
        outer: for await (const x of [Promise.resolve([0, 1])]) {
          for (const y of x) if (y) break outer
          throw 'fail'
        }
      }
      
      // Old output (with --target=es6)
      function test() {
        return __async(this, null, function* () {
          outer: try {
            for (var iter = __forAwait([Promise.resolve([0, 1])]), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
              const x = temp.value;
              for (const y of x) if (y) break outer;
              throw "fail";
            }
          } catch (temp) {
            error = [temp];
          } finally {
            try {
              more && (temp = iter.return) && (yield temp.call(iter));
            } finally {
              if (error)
                throw error[0];
            }
          }
        });
      }
      
      // New output (with --target=es6)
      function test() {
        return __async(this, null, function* () {
          try {
            outer: for (var iter = __forAwait([Promise.resolve([0, 1])]), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
              const x = temp.value;
              for (const y of x) if (y) break outer;
              throw "fail";
            }
          } catch (temp) {
            error = [temp];
          } finally {
            try {
              more && (temp = iter.return) && (yield temp.call(iter));
            } finally {
              if (error)
                throw error[0];
            }
          }
        });
      }
    • Do additional constant folding after cross-module enum inlining (#3416, #3425)

      This release adds a few more cases where esbuild does constant folding after cross-module enum inlining.

      // Original code: enum.ts
      export enum Platform {
        WINDOWS = 'windows',
        MACOS = 'macos',
        LINUX = 'linux',
      }
      
      // Original code: main.ts
      import { Platform } from './enum';
      declare const PLATFORM: string;
      export function logPlatform() {
        if (PLATFORM == Platform.WINDOWS) console.log('Windows');
        else if (PLATFORM == Platform.MACOS) console.log('macOS');
        else if (PLATFORM == Platform.LINUX) console.log('Linux');
        else console.log('Other');
      }
      
      // Old output (with --bundle '--define:PLATFORM="macos"' --minify --format=esm)
      function n(){"windows"=="macos"?console.log("Windows"):"macos"=="macos"?console.log("macOS"):"linux"=="macos"?console.log("Linux"):console.log("Other")}export{n as logPlatform};
      
      // New output (with --bundle '--define:PLATFORM="macos"' --minify --format=esm)
      function n(){console.log("macOS")}export{n as logPlatform};
  42. 0.21.3

    15 May 2024
    • Implement the decorator metadata proposal

      This release implements the decorator metadata proposal, which is a sub-proposal of the decorators proposal. Microsoft shipped the decorators proposal in TypeScript 5.0 and the decorator metadata proposal in TypeScript 5.2, so it's important that esbuild also supports both of these features. Here's a quick example:

      // Shim the "Symbol.metadata" symbol
      Symbol.metadata ??= Symbol('Symbol.metadata')
      
      const track = (_, context) => {
        (context.metadata.names ||= []).push(context.name)
      }
      
      class Foo {
        @track foo = 1
        @track bar = 2
      }
      
      // Prints ["foo", "bar"]
      console.log(Foo[Symbol.metadata].names)

      ⚠️ WARNING ⚠️

      This proposal has been marked as "stage 3" which means "recommended for implementation". However, it's still a work in progress and isn't a part of JavaScript yet, so keep in mind that any code that uses JavaScript decorator metadata may need to be updated as the feature continues to evolve. If/when that happens, I will update esbuild's implementation to match the specification. I will not be supporting old versions of the specification.

    • Fix bundled decorators in derived classes

      In certain cases, bundling code that uses decorators in a derived class with a class body that references its own class name could previously generate code that crashes at run-time due to an incorrect variable name. This problem has been fixed. Here is an example of code that was compiled incorrectly before this fix:

      class Foo extends Object {
        @(x => x) foo() {
          return Foo
        }
      }
      console.log(new Foo().foo())
    • Fix tsconfig.json files inside symlinked directories

      This release fixes an issue with a scenario involving a tsconfig.json file that extends another file from within a symlinked directory that uses the paths feature. In that case, the implicit baseURL value should be based on the real path (i.e. after expanding all symbolic links) instead of the original path. This was already done for other files that esbuild resolves but was not yet done for tsconfig.json because it's special-cased (the regular path resolver can't be used because the information inside tsconfig.json is involved in path resolution). Note that this fix no longer applies if the --preserve-symlinks setting is enabled.

  43. 0.21.2

    12 May 2024
    • Correct this in field and accessor decorators

      This release changes the value of this in initializers for class field and accessor decorators from the module-level this value to the appropriate this value for the decorated element (either the class or the instance). It was previously incorrect due to lack of test coverage. Here's an example of a decorator that doesn't work without this change:

      const dec = () => function() { this.bar = true }
      class Foo { @dec static foo }
      console.log(Foo.bar) // Should be "true"
    • Allow es2023 as a target environment

      TypeScript recently added es2023 as a compilation target, so esbuild now supports this too. There is no difference between a target of es2022 and es2023 as far as esbuild is concerned since the 2023 edition of JavaScript doesn't introduce any new syntax features.

  44. 0.21.1

    7 May 2024
    • Fix a regression with --keep-names

      The previous release introduced a regression with the --keep-names setting and object literals with get/set accessor methods, in which case the generated code contained syntax errors. This release fixes the regression:

      // Original code
      x = { get y() {} }
      
      // Output from version 0.21.0 (with --keep-names)
      x = { get y: /* @__PURE__ */ __name(function() {
      }, "y") };
      
      // Output from this version (with --keep-names)
      x = { get y() {
      } };
  45. 0.21.0

    7 May 2024
    • Implement the JavaScript decorators proposal

      With this release, esbuild now contains an implementation of the upcoming JavaScript decorators proposal. This is the same feature that shipped in TypeScript 5.0 and has been highly-requested on esbuild's issue tracker. You can read more about them in that blog post and in this other (now slightly outdated) extensive blog post here: 2ality.com/2022/10/javascript-decorators.html. Here's a quick example:

      const log = (fn, context) => function() {
        console.log(`before ${context.name}`)
        const it = fn.apply(this, arguments)
        console.log(`after ${context.name}`)
        return it
      }
      
      class Foo {
        @log static foo() {
          console.log('in foo')
        }
      }
      
      // Logs "before foo", "in foo", "after foo"
      Foo.foo()

      Note that this feature is different than the existing "TypeScript experimental decorators" feature that esbuild already implements. It uses similar syntax but behaves very differently, and the two are not compatible (although it's sometimes possible to write decorators that work with both). TypeScript experimental decorators will still be supported by esbuild going forward as they have been around for a long time, are very widely used, and let you do certain things that are not possible with JavaScript decorators (such as decorating function parameters). By default esbuild will parse and transform JavaScript decorators, but you can tell esbuild to parse and transform TypeScript experimental decorators instead by setting "experimentalDecorators": true in your tsconfig.json file.

      Probably at least half of the work for this feature went into creating a test suite that exercises many of the proposal's edge cases: github.com/evanw/decorator-tests. It has given me a reasonable level of confidence that esbuild's initial implementation is acceptable. However, I don't have access to a significant sample of real code that uses JavaScript decorators. If you're currently using JavaScript decorators in a real code base, please try out esbuild's implementation and let me know if anything seems off.

      ⚠️ WARNING ⚠️

      This proposal has been in the works for a very long time (work began around 10 years ago in 2014) and it is finally getting close to becoming part of the JavaScript language. However, it's still a work in progress and isn't a part of JavaScript yet, so keep in mind that any code that uses JavaScript decorators may need to be updated as the feature continues to evolve. The decorators proposal is pretty close to its final form but it can and likely will undergo some small behavioral adjustments before it ends up becoming a part of the standard. If/when that happens, I will update esbuild's implementation to match the specification. I will not be supporting old versions of the specification.

    • Optimize the generated code for private methods

      Previously when lowering private methods for old browsers, esbuild would generate one WeakSet for each private method. This mirrors similar logic for generating one WeakSet for each private field. Using a separate WeakMap for private fields is necessary as their assignment can be observable:

      let it
      class Bar {
        constructor() {
          it = this
        }
      }
      class Foo extends Bar {
        #x = 1
        #y = null.foo
        static check() {
          console.log(#x in it, #y in it)
        }
      }
      try { new Foo } catch {}
      Foo.check()

      This prints true false because this partially-initialized instance has #x but not #y. In other words, it's not true that all class instances will always have all of their private fields. However, the assignment of private methods to a class instance is not observable. In other words, it's true that all class instances will always have all of their private methods. This means esbuild can lower private methods into code where all methods share a single WeakSet, which is smaller, faster, and uses less memory. Other JavaScript processing tools such as the TypeScript compiler already make this optimization. Here's what this change looks like:

      // Original code
      class Foo {
        #x() { return this.#x() }
        #y() { return this.#y() }
        #z() { return this.#z() }
      }
      
      // Old output (--supported:class-private-method=false)
      var _x, x_fn, _y, y_fn, _z, z_fn;
      class Foo {
        constructor() {
          __privateAdd(this, _x);
          __privateAdd(this, _y);
          __privateAdd(this, _z);
        }
      }
      _x = new WeakSet();
      x_fn = function() {
        return __privateMethod(this, _x, x_fn).call(this);
      };
      _y = new WeakSet();
      y_fn = function() {
        return __privateMethod(this, _y, y_fn).call(this);
      };
      _z = new WeakSet();
      z_fn = function() {
        return __privateMethod(this, _z, z_fn).call(this);
      };
      
      // New output (--supported:class-private-method=false)
      var _Foo_instances, x_fn, y_fn, z_fn;
      class Foo {
        constructor() {
          __privateAdd(this, _Foo_instances);
        }
      }
      _Foo_instances = new WeakSet();
      x_fn = function() {
        return __privateMethod(this, _Foo_instances, x_fn).call(this);
      };
      y_fn = function() {
        return __privateMethod(this, _Foo_instances, y_fn).call(this);
      };
      z_fn = function() {
        return __privateMethod(this, _Foo_instances, z_fn).call(this);
      };
    • Fix an obscure bug with lowering class members with computed property keys

      When class members that use newer syntax features are transformed for older target environments, they sometimes need to be relocated. However, care must be taken to not reorder any side effects caused by computed property keys. For example, the following code must evaluate a() then b() then c():

      class Foo {
        [a()]() {}
        [b()];
        static { c() }
      }

      Previously esbuild did this by shifting the computed property key forward to the next spot in the evaluation order. Classes evaluate all computed keys first and then all static class elements, so if the last computed key needs to be shifted, esbuild previously inserted a static block at start of the class body, ensuring it came before all other static class elements:

      var _a;
      class Foo {
        constructor() {
          __publicField(this, _a);
        }
        static {
          _a = b();
        }
        [a()]() {
        }
        static {
          c();
        }
      }

      However, this could cause esbuild to accidentally generate a syntax error if the computed property key contains code that isn't allowed in a static block, such as an await expression. With this release, esbuild fixes this problem by shifting the computed property key backward to the previous spot in the evaluation order instead, which may push it into the extends clause or even before the class itself:

      // Original code
      class Foo {
        [a()]() {}
        [await b()];
        static { c() }
      }
      
      // Old output (with --supported:class-field=false)
      var _a;
      class Foo {
        constructor() {
          __publicField(this, _a);
        }
        static {
          _a = await b();
        }
        [a()]() {
        }
        static {
          c();
        }
      }
      
      // New output (with --supported:class-field=false)
      var _a, _b;
      class Foo {
        constructor() {
          __publicField(this, _a);
        }
        [(_b = a(), _a = await b(), _b)]() {
        }
        static {
          c();
        }
      }
  46. 0.20.x
  47. 0.20.2

    14 Mar 2024
    • Support TypeScript experimental decorators on abstract class fields

      With this release, you can now use TypeScript experimental decorators on abstract class fields. This was silently compiled incorrectly in esbuild 0.19.7 and below, and was an error from esbuild 0.19.8 to esbuild 0.20.1. Code such as the following should now work correctly:

      // Original code
      const log = (x: any, y: string) => console.log(y)
      abstract class Foo { @log abstract foo: string }
      new class extends Foo { foo = '' }
      
      // Old output (with --loader=ts --tsconfig-raw={\"compilerOptions\":{\"experimentalDecorators\":true}})
      const log = (x, y) => console.log(y);
      class Foo {
      }
      new class extends Foo {
        foo = "";
      }();
      
      // New output (with --loader=ts --tsconfig-raw={\"compilerOptions\":{\"experimentalDecorators\":true}})
      const log = (x, y) => console.log(y);
      class Foo {
      }
      __decorateClass([
        log
      ], Foo.prototype, "foo", 2);
      new class extends Foo {
        foo = "";
      }();
    • JSON loader now preserves __proto__ properties

      Copying JSON source code into a JavaScript file will change its meaning if a JSON object contains the __proto__ key. A literal __proto__ property in a JavaScript object literal sets the prototype of the object instead of adding a property named __proto__, while a literal __proto__ property in a JSON object literal just adds a property named __proto__. With this release, esbuild will now work around this problem by converting JSON to JavaScript with a computed property key in this case:

      // Original code
      import data from 'data:application/json,{"__proto__":{"fail":true}}'
      if (Object.getPrototypeOf(data)?.fail) throw 'fail'
      
      // Old output (with --bundle)
      (() => {
        // <data:application/json,{"__proto__":{"fail":true}}>
        var json_proto_fail_true_default = { __proto__: { fail: true } };
      
        // entry.js
        if (Object.getPrototypeOf(json_proto_fail_true_default)?.fail)
          throw "fail";
      })();
      
      // New output (with --bundle)
      (() => {
        // <data:application/json,{"__proto__":{"fail":true}}>
        var json_proto_fail_true_default = { ["__proto__"]: { fail: true } };
      
        // example.mjs
        if (Object.getPrototypeOf(json_proto_fail_true_default)?.fail)
          throw "fail";
      })();
    • Improve dead code removal of switch statements

      With this release, esbuild will now remove switch statements in branches when minifying if they are known to never be evaluated:

      // Original code
      if (true) foo(); else switch (bar) { case 1: baz(); break }
      
      // Old output (with --minify)
      if(1)foo();else switch(bar){case 1:}
      
      // New output (with --minify)
      foo();
  48. 0.20.1

    19 Feb 2024
    • Fix a bug with the CSS nesting transform

      This release fixes a bug with the CSS nesting transform for older browsers where the generated CSS could be incorrect if a selector list contained a pseudo element followed by another selector. The bug was caused by incorrectly mutating the parent rule's selector list when filtering out pseudo elements for the child rules:

      /* Original code */
      .foo {
        &:after,
        & .bar {
          color: red;
        }
      }
      
      /* Old output (with --supported:nesting=false) */
      .foo .bar,
      .foo .bar {
        color: red;
      }
      
      /* New output (with --supported:nesting=false) */
      .foo:after,
      .foo .bar {
        color: red;
      }
    • Constant folding for JavaScript inequality operators

      This release introduces constant folding for the < > <= >= operators. The minifier will now replace these operators with true or false when both sides are compile-time numeric or string constants:

      // Original code
      console.log(1 < 2, '🍕' > '🧀')
      
      // Old output (with --minify)
      console.log(1<2,"🍕">"🧀");
      
      // New output (with --minify)
      console.log(!0,!1);
    • Better handling of __proto__ edge cases

      JavaScript object literal syntax contains a special case where a non-computed property with a key of __proto__ sets the prototype of the object. This does not apply to computed properties or to properties that use the shorthand property syntax introduced in ES6. Previously esbuild didn't correctly preserve the "sets the prototype" status of properties inside an object literal, meaning a property that sets the prototype could accidentally be transformed into one that doesn't and vice versa. This has now been fixed:

      // Original code
      function foo(__proto__) {
        return { __proto__: __proto__ } // Note: sets the prototype
      }
      function bar(__proto__, proto) {
        {
          let __proto__ = proto
          return { __proto__ } // Note: doesn't set the prototype
        }
      }
      
      // Old output
      function foo(__proto__) {
        return { __proto__ }; // Note: no longer sets the prototype (WRONG)
      }
      function bar(__proto__, proto) {
        {
          let __proto__2 = proto;
          return { __proto__: __proto__2 }; // Note: now sets the prototype (WRONG)
        }
      }
      
      // New output
      function foo(__proto__) {
        return { __proto__: __proto__ }; // Note: sets the prototype (correct)
      }
      function bar(__proto__, proto) {
        {
          let __proto__2 = proto;
          return { ["__proto__"]: __proto__2 }; // Note: doesn't set the prototype (correct)
        }
      }
  49. 0.20.0

    27 Jan 2024
    • Work around API deprecations in Deno 1.40.x (#3609, #3611)

      Deno 1.40.0 was just released and introduced run-time warnings about certain APIs that esbuild uses. With this release, esbuild will work around these run-time warnings by using newer APIs if they are present and falling back to the original APIs otherwise. This should avoid the warnings without breaking compatibility with older versions of Deno.

      Unfortunately, doing this introduces a breaking change. The newer child process APIs lack a way to synchronously terminate esbuild's child process, so calling esbuild.stop() from within a Deno test is no longer sufficient to prevent Deno from failing a test that uses esbuild's API (Deno fails tests that create a child process without killing it before the test ends). To work around this, esbuild's stop() function has been changed to return a promise, and you now have to change esbuild.stop() to await esbuild.stop() in all of your Deno tests.

    • Reorder implicit file extensions within node_modules (#3341, #3608)

      In version 0.18.0, esbuild changed the behavior of implicit file extensions within node_modules directories (i.e. in published packages) to prefer .js over .ts even when the --resolve-extensions= order prefers .ts over .js (which it does by default). However, doing that also accidentally made esbuild prefer .css over .ts, which caused problems for people that published packages containing both TypeScript and CSS in files with the same name.

      With this release, esbuild will reorder TypeScript file extensions immediately after the last JavaScript file extensions in the implicit file extension order instead of putting them at the end of the order. Specifically the default implicit file extension order is .tsx,.ts,.jsx,.js,.css,.json which used to become .jsx,.js,.css,.json,.tsx,.ts in node_modules directories. With this release it will now become .jsx,.js,.tsx,.ts,.css,.json instead.

      Why even rewrite the implicit file extension order at all? One reason is because the .js file is more likely to behave correctly than the .ts file. The behavior of the .ts file may depend on tsconfig.json and the tsconfig.json file may not even be published, or may use extends to refer to a base tsconfig.json file that wasn't published. People can get into this situation when they forget to add all .ts files to their .npmignore file before publishing to npm. Picking .js over .ts helps make it more likely that resulting bundle will behave correctly.

  50. 0.19.x
  51. 0.19.12

    23 Jan 2024

    Reading the note…

  52. 0.19.11

    29 Dec 2023
    • Fix TypeScript-specific class transform edge case

      The previous release introduced an optimization that avoided transforming super() in the class constructor for TypeScript code compiled with useDefineForClassFields set to false if all class instance fields have no initializers. The rationale was that in this case, all class instance fields are omitted in the output so no changes to the constructor are needed. However, if all of this is the case and there are #private instance fields with initializers, those private instance field initializers were still being moved into the constructor. This was problematic because they were being inserted before the call to super() (since super() is now no longer transformed in that case). This release introduces an additional optimization that avoids moving the private instance field initializers into the constructor in this edge case, which generates smaller code, matches the TypeScript compiler's output more closely, and avoids this bug:

      // Original code
      class Foo extends Bar {
        #private = 1;
        public: any;
        constructor() {
          super();
        }
      }
      
      // Old output (with esbuild v0.19.9)
      class Foo extends Bar {
        constructor() {
          super();
          this.#private = 1;
        }
        #private;
      }
      
      // Old output (with esbuild v0.19.10)
      class Foo extends Bar {
        constructor() {
          this.#private = 1;
          super();
        }
        #private;
      }
      
      // New output
      class Foo extends Bar {
        #private = 1;
        constructor() {
          super();
        }
      }
    • Minifier: Allow reording a primitive past a side-effect

      The minifier previously allowed reordering a side-effect past a primitive, but didn't handle the case of reordering a primitive past a side-effect. This additional case is now handled:

      // Original code
      function f() {
        let x = false;
        let y = x;
        const boolean = y;
        let frag = $.template(`<p contenteditable="${boolean}">hello world</p>`);
        return frag;
      }
      
      // Old output (with --minify)
      function f(){const e=!1;return $.template(`<p contenteditable="${e}">hello world</p>`)}
      
      // New output (with --minify)
      function f(){return $.template('<p contenteditable="false">hello world</p>')}
    • Minifier: Consider properties named using known Symbol instances to be side-effect free

      Many things in JavaScript can have side effects including property accesses and ToString operations, so using a symbol such as Symbol.iterator as a computed property name is not obviously side-effect free. This release adds a special case for known Symbol instances so that they are considered side-effect free when used as property names. For example, this class declaration will now be considered side-effect free:

      class Foo {
        *[Symbol.iterator]() {
        }
      }
  53. 0.19.10

    19 Dec 2023

    Reading the note…

  54. 0.19.9

    10 Dec 2023

    Reading the note…

  55. 0.19.8

    26 Nov 2023

    Reading the note…

  56. 0.19.7

    21 Nov 2023

    Reading the note…

  57. 0.19.6

    19 Nov 2023

    Reading the note…

  58. 0.19.5

    17 Oct 2023

    Reading the note…

  59. 0.19.4

    28 Sep 2023

    Reading the note…

  60. 0.19.3

    14 Sep 2023

    Reading the note…

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.