npm esbuild 0.8.29
v0.8.29

latest releases: 0.21.3, 0.21.2, 0.21.1...
3 years ago
  • Allow entry points outside of the outbase directory (#634)

    When esbuild generates the output path for a bundled entry point, it computes the relative path from the outbase directory to the input entry point file and then joins that relative path to the output directory. For example, if there are two entry points src/pages/home/index.ts and src/pages/about/index.ts, the outbase directory is src, and the output directory is out, the output directory will contain out/pages/home/index.js and out/pages/about/index.js.

    However, this means that the outbase directory is expected to contain all entry point files (even implicit entry point files from import() expressions). If an entry point isn't under the outbase directory then esbuild will to try to write the output file outside of the output directory, since the path of the entry point relative to outbase will start with ../ which is then joined to the output directory. This is unintentional. All output files are supposed to be written inside of the output directory.

    This release fixes the problem by creating a directory with the name _.._ in the output directory for output file paths of entry points that are not inside the outbase directory. So if the previous example was bundled with an outbase directory of temp, the output directory will contain out/_.._/pages/home/index.js and out/_.._/pages/about/index.js. Doing this instead of stripping the leading ../ off the relative path is necessary to avoid collisions between different entry points with the same path suffix.

  • Minification improvements

    This release contains the following minification improvements:

    • Expressions of the form !(a == b) are now converted to a != b. This also applies similarly for the other three equality operators.

    • A trailing continue; statement inside the body of a loop is now removed.

    • Minification can now omit certain continue and return statements when it's implied by control flow:

      // Before minification
      function fn() {
        if (a) return;
        while (b) {
          if (c) continue;
          d();
        }
      }
      
      // After minification
      function fn() {
        if (!a)
          for (; b; )
            c || d();
      }
    • Certain single-use variables are now inlined if the use directly follows the variable:

      // Before minification
      let result = fn();
      let callback = result.callback;
      return callback.call(this);
      // After minification
      return fn().callback.call(this);

      This transformation is only done when it's safe to do so. The safety conditions are complex but at a high level, an expression cannot be reordered past another expression if either of them could possibly have side effects.

Don't miss a new esbuild release

NewReleases is sending notifications on new releases.