npm esbuild 0.8.41
v0.8.41

latest releases: 0.24.0, 0.23.1, 0.23.0...
3 years ago
  • Fix memory leak with watch mode when using the CLI (#750)

    This release fixes a memory leak when using --watch from the CLI (command-line interface). When esbuild was in this state, every incremental build resulted in more memory being consumed. This problem did not affect users of the JS API or Go API, only users of the CLI API.

    The problem was that the GC (garbage collector) was disabled. Oops. This is done by default for speed when you use esbuild via the CLI, which makes sense for most CLI use cases because the process is usually short-lived and doesn't need to waste time cleaning up memory. But it does not make sense for flags that cause esbuild to be a long-running process.

    Previously the only exception to this rule was the --serve flag. When I added watch mode, I forgot to enable GC for the --watch flag too. With this release, the GC is enabled for both the --serve and the --watch flags so esbuild should no longer leak memory in watch mode.

  • Special-case certain syntax with --format=esm (#749)

    You can now no longer use the following syntax features with the esm output format:

    • The with statement: with (x) {}
    • Delete of a bare identifier: delete x

    In addition, the following syntax feature is transformed when using the esm output format:

    • For-in variable initializers: for (var x = y in {}) {}x = y; for (var x in {}) {}

    The reason is because all JavaScript engines interpret code in the esm output format as strict mode and these syntax features are disallowed in strict mode. Note that this new strict mode handling behavior in esbuild is only dependent on the output format. It does not depend on the presence or absence of "use strict" directives.

  • Basic "use strict" tracking

    The JavaScript parser now tracks "use strict" directives and propagates strict mode status through the code. In addition, files containing the import and/or export keywords are also considered to be in strict mode. Strict mode handling is complex and esbuild currently doesn't implement all strict mode checks. But the changes in this release are a starting point. It is now an error to use certain syntax features such as a with statement within a strict mode scope.

  • Fix a minifier bug with with statements

    The minifier removes references to local variables if they are unused. However, that's not correct to do inside a with statement scope because what appears to be an identifier may actually be a property access, and property accesses could have arbitrary side effects if they resolve to a getter or setter method. Now all identifier expressions inside with statements are preserved when minifying.

  • Transform block-level function declarations

    Block-level function declarations are now transformed into equivalent syntax that avoids block-level declarations. Strict mode and non-strict mode have subtly incompatible behavior for how block-level function declarations are interpreted. Doing this transformation prevents problems with code that was originally strict mode that is run as non-strict mode and vice versa.

    Now esbuild uses the presence or absence of a strict mode scope to determine how to interpret the block-level function declaration and then converts it to the equivalent unambiguous syntax such that it works the same regardless of whether or not the current scope is in strict mode:

    // This original code:
    while (!y) {
      function y() {}
    }
    
    // is transformed into this code in strict mode:
    while (!y) {
      let y2 = function() {};
    }
    
    // and into this code when not in strict mode:
    while (!y) {
      let y2 = function() {};
      var y = y2;
    }

Don't miss a new esbuild release

NewReleases is sending notifications on new releases.