Packages

@esbuild/freebsd-x64

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

Your version

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

  1. 0.19.x
  2. 0.19.2

    14 Aug 2023
    • Update how CSS nesting is parsed again

      CSS nesting syntax has been changed again, and esbuild has been updated to match. Type selectors may now be used with CSS nesting:

      .foo {
        div {
          color: red;
        }
      }

      Previously this was disallowed in the CSS specification because it's ambiguous whether an identifier is a declaration or a nested rule starting with a type selector without requiring unbounded lookahead in the parser. It has now been allowed because the CSS working group has decided that requiring unbounded lookahead is acceptable after all.

      Note that this change means esbuild no longer considers any existing browser to support CSS nesting since none of the existing browsers support this new syntax. CSS nesting will now always be transformed when targeting a browser. This situation will change in the future as browsers add support for this new syntax.

    • Fix a scope-related bug with --drop-labels=

      The recently-released --drop-labels= feature previously had a bug where esbuild's internal scope stack wasn't being restored properly when a statement with a label was dropped. This could manifest as a tree-shaking issue, although it's possible that this could have also been causing other subtle problems too. The bug has been fixed in this release.

    • Make renamed CSS names unique across entry points

      Previously esbuild's generated names for local names in CSS were only unique within a given entry point (or across all entry points when code splitting was enabled). That meant that building multiple entry points with esbuild could result in local names being renamed to the same identifier even when those entry points were built simultaneously within a single esbuild API call. This problem was especially likely to happen with minification enabled. With this release, esbuild will now avoid renaming local names from two separate entry points to the same name if those entry points were built with a single esbuild API call, even when code splitting is disabled.

  3. 0.19.1

    11 Aug 2023
    • Fix a regression with baseURL in tsconfig.json

      The previous release moved tsconfig.json path resolution before --packages=external checks to allow the paths field in tsconfig.json to avoid a package being marked as external. However, that reordering accidentally broke the behavior of the baseURL field from tsconfig.json. This release moves these path resolution rules around again in an attempt to allow both of these cases to work.

    • Parse TypeScript type arguments for JavaScript decorators

      When parsing JavaScript decorators in TypeScript (i.e. with experimentalDecorators disabled), esbuild previously didn't parse type arguments. Type arguments will now be parsed starting with this release. For example:

      @foo<number>
      @bar<number, string>()
      class Foo {}
    • Fix glob patterns matching extra stuff at the end

      Previously glob patterns such as ./*.js would incorrectly behave like ./*.js* during path matching (also matching .js.map files, for example). This was never intentional behavior, and has now been fixed.

  4. 0.19.0

    8 Aug 2023
    • Handle import paths containing wildcards (#56, #700, #875, #976, #2221, #2515)

      This release introduces wildcards in import paths in two places:

    • Path aliases in tsconfig.json no longer count as packages (#2792, #3003, #3160, #3238)

      Setting --packages=external tells esbuild to make all import paths external when they look like a package path. For example, an import of ./foo/bar is not a package path and won't be external while an import of foo/bar is a package path and will be external. However, the paths field in tsconfig.json allows you to create import paths that look like package paths but that do not resolve to packages. People do not want these paths to count as package paths. So with this release, the behavior of --packages=external has been changed to happen after the tsconfig.json path remapping step.

    • Use the local-css loader for .module.css files by default

      With this release the css loader is still used for .css files except that .module.css files now use the local-css loader. This is a common convention in the web development community. If you need .module.css files to use the css loader instead, then you can override this behavior with --loader:.module.css=css.

  5. 0.18.x
  6. 0.18.20

    8 Aug 2023
    • Support advanced CSS @import rules (#953, #3137)

      CSS @import statements have been extended to allow additional trailing tokens after the import path. These tokens sort of make the imported file behave as if it were wrapped in a @layer, @supports, and/or @media rule. Here are some examples:

      @import url(foo.css);
      @import url(foo.css) layer;
      @import url(foo.css) layer(bar);
      @import url(foo.css) layer(bar) supports(display: flex);
      @import url(foo.css) layer(bar) supports(display: flex) print;
      @import url(foo.css) layer(bar) print;
      @import url(foo.css) supports(display: flex);
      @import url(foo.css) supports(display: flex) print;
      @import url(foo.css) print;

      You can read more about this advanced syntax here. With this release, esbuild will now bundle @import rules with these trailing tokens and will wrap the imported files in the corresponding rules. Note that this now means a given imported file can potentially appear in multiple places in the bundle. However, esbuild will still only load it once (e.g. on-load plugins will only run once per file, not once per import).

  7. 0.18.19

    7 Aug 2023
    • Implement composes from CSS modules

      This release implements the composes annotation from the CSS modules specification. It provides a way for class selectors to reference other class selectors (assuming you are using the local-css loader). And with the from syntax, this can even work with local names across CSS files. For example:

      // app.js
      import { submit } from './style.css'
      const div = document.createElement('div')
      div.className = submit
      document.body.appendChild(div)
      /* style.css */
      .button {
        composes: pulse from "anim.css";
        display: inline-block;
      }
      .submit {
        composes: button;
        font-weight: bold;
      }
      /* anim.css */
      @keyframes pulse {
        from, to { opacity: 1 }
        50% { opacity: 0.5 }
      }
      .pulse {
        animation: 2s ease-in-out infinite pulse;
      }

      Bundling this with esbuild using --bundle --outdir=dist --loader:.css=local-css now gives the following:

      (() => {
        // style.css
        var submit = "anim_pulse style_button style_submit";
      
        // app.js
        var div = document.createElement("div");
        div.className = submit;
        document.body.appendChild(div);
      })();
      /* anim.css */
      @keyframes anim_pulse {
        from, to {
          opacity: 1;
        }
        50% {
          opacity: 0.5;
        }
      }
      .anim_pulse {
        animation: 2s ease-in-out infinite anim_pulse;
      }
      
      /* style.css */
      .style_button {
        display: inline-block;
      }
      .style_submit {
        font-weight: bold;
      }

      Import paths in the composes: ... from syntax are resolved using the new composes-from import kind, which can be intercepted by plugins during import path resolution when bundling is enabled.

      Note that the order in which composed CSS classes from separate files appear in the bundled output file is deliberately undefined by design (see the specification for details). You are not supposed to declare the same CSS property in two separate class selectors and then compose them together. You are only supposed to compose CSS class selectors that declare non-overlapping CSS properties.

      Issue #20 (the issue tracking CSS modules) is esbuild's most-upvoted issue! With this change, I now consider esbuild's implementation of CSS modules to be complete. There are still improvements to make and there may also be bugs with the current implementation, but these can be tracked in separate issues.

    • Fix non-determinism with tsconfig.json and symlinks

      This release fixes an issue that could cause esbuild to sometimes emit incorrect build output in cases where a file under the effect of tsconfig.json is inconsistently referenced through a symlink. It can happen when using npm link to create a symlink within node_modules to an unpublished package. The build result was non-deterministic because esbuild runs module resolution in parallel and the result of the tsconfig.json lookup depended on whether the import through the symlink or not through the symlink was resolved first. This problem was fixed by moving the realpath operation before the tsconfig.json lookup.

    • Add a hash property to output files (#3084, #3293)

      As a convenience, every output file in esbuild's API now includes a hash property that is a hash of the contents field. This is the hash that's used internally by esbuild to detect changes between builds for esbuild's live-reload feature. You may also use it to detect changes between your own builds if its properties are sufficient for your use case.

      This feature has been added directly to output file objects since it's just a hash of the contents field, so it makes conceptual sense to store it in the same location. Another benefit of putting it there instead of including it as a part of the watch mode API is that it can be used without watch mode enabled. You can use it to compare the output of two independent builds that were done at different times.

      The hash algorithm (currently XXH64) is implementation-dependent and may be changed at any time in between esbuild versions. If you don't like esbuild's choice of hash algorithm then you are welcome to hash the contents yourself instead. As with any hash algorithm, note that while two different hashes mean that the contents are different, two equal hashes do not necessarily mean that the contents are equal. You may still want to compare the contents in addition to the hashes to detect with certainty when output files have been changed.

  8. 0.18.18

    5 Aug 2023
    • Fix asset references with the --line-limit flag

      The recently-released --line-limit flag tells esbuild to terminate long lines after they pass this length limit. This includes automatically wrapping long strings across multiple lines using escaped newline syntax. However, using this could cause esbuild to generate incorrect code for references from generated output files to assets in the bundle (i.e. files loaded with the file or copy loaders). This is because esbuild implements asset references internally using find-and-replace with a randomly-generated string, but the find operation fails if the string is split by an escaped newline due to line wrapping. This release fixes the problem by not wrapping these strings. This issue affected asset references in both JS and CSS files.

    • Support local names in CSS for @keyframe, @counter-style, and @container

      This release extends support for local names in CSS files loaded with the local-css loader to cover the @keyframe, @counter-style, and @container rules (and also animation, list-style, and container declarations). Here's an example:

      @keyframes pulse {
        from, to { opacity: 1 }
        50% { opacity: 0.5 }
      }
      @counter-style moon {
        system: cyclic;
        symbols: 🌕 🌖 🌗 🌘 🌑 🌒 🌓 🌔;
      }
      @container squish {
        li { float: left }
      }
      ul {
        animation: 2s ease-in-out infinite pulse;
        list-style: inside moon;
        container: squish / size;
      }

      With the local-css loader enabled, that CSS will be turned into something like this (with the local name mapping exposed to JS):

      @keyframes stdin_pulse {
        from, to {
          opacity: 1;
        }
        50% {
          opacity: 0.5;
        }
      }
      @counter-style stdin_moon {
        system: cyclic;
        symbols: 🌕 🌖 🌗 🌘 🌑 🌒 🌓 🌔;
      }
      @container stdin_squish {
        li {
          float: left;
        }
      }
      ul {
        animation: 2s ease-in-out infinite stdin_pulse;
        list-style: inside stdin_moon;
        container: stdin_squish / size;
      }

      If you want to use a global name within a file loaded with the local-css loader, you can use a :global selector to do that:

      div {
        /* All symbols are global inside this scope (i.e.
         * "pulse", "moon", and "squish" are global below) */
        :global {
          animation: 2s ease-in-out infinite pulse;
          list-style: inside moon;
          container: squish / size;
        }
      }

      If you want to use @keyframes, @counter-style, or @container with a global name, make sure it's in a file that uses the css or global-css loader instead of the local-css loader. For example, you can configure --loader:.module.css=local-css so that the local-css loader only applies to *.module.css files.

    • Support strings as keyframe animation names in CSS

      With this release, esbuild will now parse animation names that are specified as strings and will convert them to identifiers. The CSS specification allows animation names to be specified using either identifiers or strings but Chrome only understands identifiers, so esbuild will now always convert string names to identifier names for Chrome compatibility:

      /* Original code */
      @keyframes "hide menu" {
        from { opacity: 1 }
        to { opacity: 0 }
      }
      menu.hide {
        animation: 0.5s ease-in-out "hide menu";
      }
      
      /* Old output */
      @keyframes "hide menu" { from { opacity: 1 } to { opacity: 0 } }
      menu.hide {
        animation: 0.5s ease-in-out "hide menu";
      }
      
      /* New output */
      @keyframes hide\ menu {
        from {
          opacity: 1;
        }
        to {
          opacity: 0;
        }
      }
      menu.hide {
        animation: 0.5s ease-in-out hide\ menu;
      }
  9. 0.18.17

    26 Jul 2023

    Reading the note…

  10. 0.18.16

    23 Jul 2023

    Reading the note…

  11. 0.18.15

    20 Jul 2023

    Reading the note…

  12. 0.18.14

    18 Jul 2023

    Reading the note…

  13. 0.18.13

    15 Jul 2023

    Reading the note…

  14. 0.18.12

    13 Jul 2023

    Reading the note…

  15. 0.18.11

    1 Jul 2023

    Reading the note…

  16. 0.18.10

    26 Jun 2023

    Reading the note…

  17. 0.18.9

    26 Jun 2023

    Reading the note…

  18. 0.18.8

    25 Jun 2023

    Reading the note…

  19. 0.18.7

    24 Jun 2023

    Reading the note…

  20. 0.18.6

    20 Jun 2023

    Reading the note…

  21. 0.18.5

    20 Jun 2023

    Reading the note…

  22. 0.18.4

    16 Jun 2023

    Reading the note…

  23. 0.18.3

    15 Jun 2023

    Reading the note…

  24. 0.18.2

    13 Jun 2023

    Reading the note…

  25. 0.18.1

    12 Jun 2023

    Reading the note…

  26. 0.18.0

    9 Jun 2023
    • Add a way to try esbuild online

      There is now a way to try esbuild live on esbuild's website without installing it: esbuild.github.io/try/. In addition to being able to more easily evaluate esbuild, this should also make it more efficient to generate esbuild bug reports. For example, you can use it to compare the behavior of different versions of esbuild on the same input. The state of the page is stored in the URL for easy sharing. Many thanks to @hyrious for creating hyrious.me/esbuild-repl/, which was the main inspiration for this addition to esbuild's website.

      Two forms of build options are supported: either CLI-style (example) or JS-style (example). Both are converted into a JS object that's passed to esbuild's WebAssembly API. The CLI-style argument parser is a custom one that simulates shell quoting rules, and the JS-style argument parser is also custom and parses a superset of JSON (basically JSON5 + regular expressions). So argument parsing is an approximate simulation of what happens for real but hopefully it should be close enough.

    • Changes to esbuild's tsconfig.json support (#3019):

      This release makes the following changes to esbuild's tsconfig.json support:

      These changes are intended to improve esbuild's compatibility with tsc and reduce the number of unfortunate behaviors regarding tsconfig.json and esbuild.

    • Add a workaround for bugs in Safari 16.2 and earlier

      Safari's JavaScript parser had a bug (which has now been fixed) where at least something about unary/binary operators nested inside default arguments nested inside either a function or class expression was incorrectly considered a syntax error if that expression was the target of a property assignment. Here are some examples that trigger this Safari bug:

      ❱ x(function (y = -1) {}.z = 2)
      SyntaxError: Left hand side of operator '=' must be a reference.
      
      ❱ x(class { f(y = -1) {} }.z = 2)
      SyntaxError: Left hand side of operator '=' must be a reference.

      It's not clear what the exact conditions are that trigger this bug. However, a workaround for this bug appears to be to post-process your JavaScript to wrap any in function and class declarations that are the direct target of a property access expression in parentheses. That's the workaround that UglifyJS applies for this issue: mishoo/UglifyJS#2056. So that's what esbuild now does starting with this release:

      // Original code
      x(function (y = -1) {}.z = 2, class { f(y = -1) {} }.z = 2)
      
      // Old output (with --minify --target=safari16.2)
      x(function(c=-1){}.z=2,class{f(c=-1){}}.z=2);
      
      // New output (with --minify --target=safari16.2)
      x((function(c=-1){}).z=2,(class{f(c=-1){}}).z=2);

      This fix is not enabled by default. It's only enabled when --target= contains Safari 16.2 or earlier, such as with --target=safari16.2. You can also explicitly enable or disable this specific transform (called function-or-class-property-access) with --supported:function-or-class-property-access=false.

  27. 0.17.x
  28. 0.17.19

    13 May 2023

    Reading the note…

  29. 0.17.18

    22 Apr 2023

    Reading the note…

  30. 0.17.17

    16 Apr 2023

    Reading the note…

  31. 0.17.16

    10 Apr 2023

    Reading the note…

  32. 0.17.15

    1 Apr 2023

    Reading the note…

  33. 0.17.14

    26 Mar 2023

    Reading the note…

  34. 0.17.13

    24 Mar 2023

    Reading the note…

  35. 0.17.12

    17 Mar 2023

    Reading the note…

  36. 0.17.11

    3 Mar 2023
    • Fix the alias feature to always prefer the longest match

      It's possible to configure conflicting aliases such as --alias:a=b and --alias:a/c=d, which is ambiguous for the import path a/c/x (since it could map to either b/c/x or d/x). Previously esbuild would pick the first matching alias, which would non-deterministically pick between one of the possible matches. This release fixes esbuild to always deterministically pick the longest possible match.

    • Minify calls to some global primitive constructors

      With this release, esbuild's minifier now replaces calls to Boolean/Number/String/BigInt with equivalent shorter code when relevant:

      // Original code
      console.log(
        Boolean(a ? (b | c) !== 0 : (c & d) !== 0),
        Number(e ? '1' : '2'),
        String(e ? '1' : '2'),
        BigInt(e ? 1n : 2n),
      )
      
      // Old output (with --minify)
      console.log(Boolean(a?(b|c)!==0:(c&d)!==0),Number(e?"1":"2"),String(e?"1":"2"),BigInt(e?1n:2n));
      
      // New output (with --minify)
      console.log(!!(a?b|c:c&d),+(e?"1":"2"),e?"1":"2",e?1n:2n);
    • Adjust some feature compatibility tables for node

      This release makes the following adjustments to esbuild's internal feature compatibility tables for node, which tell esbuild which versions of node are known to support all aspects of that feature:

      Each of these adjustments was identified by comparing against data from the node-compat-table package and was manually verified using old node executables downloaded from nodejs.org/download/release/.

  37. 0.17.10

    20 Feb 2023

    Reading the note…

  38. 0.17.9

    19 Feb 2023

    Reading the note…

  39. 0.17.8

    13 Feb 2023

    Reading the note…

  40. 0.17.7

    9 Feb 2023

    Reading the note…

  41. 0.17.6

    6 Feb 2023

    Reading the note…

  42. 0.17.5

    27 Jan 2023

    Reading the note…

  43. 0.17.4

    22 Jan 2023

    Reading the note…

  44. 0.17.3

    18 Jan 2023

    Reading the note…

  45. 0.17.2

    17 Jan 2023

    Reading the note…

  46. 0.17.1

    16 Jan 2023
    • Make it possible to cancel a build

      The context object introduced in version 0.17.0 has a new cancel() method. You can use it to cancel a long-running build so that you can start a new one without needing to wait for the previous one to finish. When this happens, the previous build should always have at least one error and have no output files (i.e. it will be a failed build).

      Using it might look something like this:

      This API is a quick implementation and isn't maximally efficient, so the build may continue to do some work for a little bit before stopping. For example, I have added stop points between each top-level phase of the bundler and in the main module graph traversal loop, but I haven't added fine-grained stop points within the internals of the linker. How quickly esbuild stops can be improved in future releases. This means you'll want to wait for cancel() and/or the previous rebuild() to finish (i.e. await the returned promise in JavaScript) before starting a new build, otherwise rebuild() will give you the just-canceled build that still hasn't ended yet. Note that onEnd callbacks will still be run regardless of whether or not the build was canceled.

    • Fix server-sent events without servedir

      The server-sent events for live reload were incorrectly using servedir to calculate the path to modified output files. This means events couldn't be sent when servedir wasn't specified. This release uses the internal output directory (which is always present) instead of servedir (which might be omitted), so live reload should now work when servedir is not specified.

    • Custom entry point output paths now work with the copy loader

      Entry points can optionally provide custom output paths to change the path of the generated output file. For example, esbuild foo=abc.js bar=xyz.js --outdir=out generates the files out/foo.js and out/bar.js. However, this previously didn't work when using the copy loader due to an oversight. This bug has been fixed. For example, you can now do esbuild foo=abc.html bar=xyz.html --outdir=out --loader:.html=copy to generate the files out/foo.html and out/bar.html.

  47. 0.17.0

    14 Jan 2023
    • Move everything related to incremental builds to a new context API (#1037, #1606, #2280, #2418)

      This change removes the incremental and watch options as well as the serve() method, and introduces a new context() method. The context method takes the same arguments as the build() method but only validates its arguments and does not do an initial build. Instead, builds can be triggered using the rebuild(), watch(), and serve() methods on the returned context object. The new context API looks like this:

      // Create a context for incremental builds
      const context = await esbuild.context({
        entryPoints: ['app.ts'],
        bundle: true,
      })
      
      // Manually do an incremental build
      const result = await context.rebuild()
      
      // Enable watch mode
      await context.watch()
      
      // Enable serve mode
      await context.serve()
      
      // Dispose of the context
      context.dispose()

      The switch to the context API solves a major issue with the previous API which is that if the initial build fails, a promise is thrown in JavaScript which prevents you from accessing the returned result object. That prevented you from setting up long-running operations such as watch mode when the initial build contained errors. It also makes tearing down incremental builds simpler as there is now a single way to do it instead of three separate ways.

      In addition, this release also makes some subtle changes to how incremental builds work. Previously every call to rebuild() started a new build. If you weren't careful, then builds could actually overlap. This doesn't cause any problems with esbuild itself, but could potentially cause problems with plugins (esbuild doesn't even give you a way to identify which overlapping build a given plugin callback is running on). Overlapping builds also arguably aren't useful, or at least aren't useful enough to justify the confusion and complexity that they bring. With this release, there is now only ever a single active build per context. Calling rebuild() before the previous rebuild has finished now "merges" with the existing rebuild instead of starting a new build.

    • Allow using watch and serve together (#805, #1650, #2576)

      Previously it was not possible to use watch mode and serve mode together. The rationale was that watch mode is one way of automatically rebuilding your project and serve mode is another (since serve mode automatically rebuilds on every request). However, people want to combine these two features to make "live reloading" where the browser automatically reloads the page when files are changed on the file system.

      This release now allows you to use these two features together. You can only call the watch() and serve() APIs once each per context, but if you call them together on the same context then esbuild will automatically rebuild both when files on the file system are changed and when the server serves a request.

    • Support "live reloading" through server-sent events

      Server-sent events are a simple way to pass one-directional messages asynchronously from the server to the client. Serve mode now provides a /esbuild endpoint with an change event that triggers every time esbuild's output changes. So you can now implement simple "live reloading" (i.e. reloading the page when a file is edited and saved) like this:

      new EventSource('/esbuild').addEventListener('change', () => location.reload())

      The event payload is a JSON object with the following shape:

      interface ChangeEvent {
        added: string[]
        removed: string[]
        updated: string[]
      }

      This JSON should also enable more complex live reloading scenarios. For example, the following code hot-swaps changed CSS <link> tags in place without reloading the page (but still reloads when there are other types of changes):

      new EventSource('/esbuild').addEventListener('change', e => {
        const { added, removed, updated } = JSON.parse(e.data)
        if (!added.length && !removed.length && updated.length === 1) {
          for (const link of document.getElementsByTagName("link")) {
            const url = new URL(link.href)
            if (url.host === location.host && url.pathname === updated[0]) {
              const next = link.cloneNode()
              next.href = updated[0] + '?' + Math.random().toString(36).slice(2)
              next.onload = () => link.remove()
              link.parentNode.insertBefore(next, link.nextSibling)
              return
            }
          }
        }
        location.reload()
      })

      Implementing live reloading like this has a few known caveats:

  48. 0.16.x
  49. 0.16.17

    11 Jan 2023
    • Fix additional comment-related regressions

      This release fixes more edge cases where the new comment preservation behavior that was added in 0.16.14 could introduce syntax errors. Specifically:

      x = () => (/* comment */ {})
      for ((/* comment */ let).x of y) ;
      function *f() { yield (/* comment */class {}) }

      These cases caused esbuild to generate code with a syntax error in version 0.16.14 or above. These bugs have now been fixed.

  50. 0.16.16

    8 Jan 2023
    • Fix a regression caused by comment preservation

      The new comment preservation behavior that was added in 0.16.14 introduced a regression where comments in certain locations could cause esbuild to omit certain necessary parentheses in the output. The outermost parentheses were incorrectly removed for the following syntax forms, which then introduced syntax errors:

      (/* comment */ { x: 0 }).x;
      (/* comment */ function () { })();
      (/* comment */ class { }).prototype;

      This regression has been fixed.

  51. 0.16.15

    7 Jan 2023

    Reading the note…

  52. 0.16.14

    4 Jan 2023
    • Preserve some comments in expressions

      Various tools give semantic meaning to comments embedded inside of expressions. For example, Webpack and Vite have special "magic comments" that can be used to affect code splitting behavior:

      import(/* webpackChunkName: "foo" */ '../foo');
      import(/* @vite-ignore */ dynamicVar);
      new Worker(/* webpackChunkName: "bar" */ new URL("../bar.ts", import.meta.url));
      new Worker(new URL('./path', import.meta.url), /* @vite-ignore */ dynamicOptions);

      Since esbuild can be used as a preprocessor for these tools (e.g. to strip TypeScript types), it can be problematic if esbuild doesn't do additional work to try to retain these comments. Previously esbuild special-cased Webpack comments in these specific locations in the AST. But Vite would now like to use similar comments, and likely other tools as well.

      So with this release, esbuild now will attempt to preserve some comments inside of expressions in more situations than before. This behavior is mainly intended to preserve these special "magic comments" that are meant for other tools to consume, although esbuild will no longer only preserve Webpack-specific comments so it should now be tool-agnostic. There is no guarantee that all such comments will be preserved (especially when --minify-syntax is enabled). So this change does not mean that esbuild is now usable as a code formatter. In particular comment preservation is more likely to happen with leading comments than with trailing comments. You should put comments that you want to be preserved before the relevant expression instead of after it. Also note that this change does not retain any more statement-level comments than before (i.e. comments not embedded inside of expressions). Comment preservation is not enabled when --minify-whitespace is enabled (which is automatically enabled when you use --minify).

  53. 0.16.13

    2 Jan 2023
    • Publish a new bundle visualization tool

      While esbuild provides bundle metadata via the --metafile flag, previously esbuild left analysis of it completely up to third-party tools (well, outside of the rudimentary --analyze flag). However, the esbuild website now has a built-in bundle visualization tool:

      You can pass --metafile to esbuild to output bundle metadata, then upload that JSON file to this tool to visualize your bundle. This is helpful for answering questions such as:

      I'm publishing this tool because I think esbuild should provide some answer to "how do I visualize my bundle" without requiring people to reach for third-party tools. At the moment the tool offers two types of visualizations: a radial "sunburst chart" and a linear "flame chart". They serve slightly different but overlapping use cases (e.g. the sunburst chart is more keyboard-accessible while the flame chart is easier with the mouse). This tool may continue to evolve over time.

    • Fix --metafile and --mangle-cache with --watch

      The CLI calls the Go API and then also writes out the metafile and/or mangle cache JSON files if those features are enabled. This extra step is necessary because these files are returned by the Go API as in-memory strings. However, this extra step accidentally didn't happen for all builds after the initial build when watch mode was enabled. This behavior used to work but it was broken in version 0.14.18 by the introduction of the mangle cache feature. This release fixes the combination of these features, so the metafile and mangle cache features should now work with watch mode. This behavior was only broken for the CLI, not for the JS or Go APIs.

    • Add an original field to the metafile

      The metadata file JSON now has an additional field: each import in an input file now contains the pre-resolved path in the original field in addition to the post-resolved path in the path field. This means it's now possible to run certain additional analysis over your bundle. For example, you should be able to use this to detect when the same package subpath is represented multiple times in the bundle, either because multiple versions of a package were bundled or because a package is experiencing the dual-package hazard.

  54. 0.16.12

    28 Dec 2022

    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.