Skip to content

v0.8.49

Compare
Choose a tag to compare
@github-actions github-actions released this 19 Feb 08:36
  • Work around a problem with pnpm and NODE_PATH (#816)

    In version 0.8.43, esbuild added support for node's NODE_PATH environment variable which contains a list of global folders to use during path resolution. However, this causes a problem when esbuild is installed with pnpm, an alternative JavaScript package manager. Specifically pnpm adds a bogus path to NODE_PATH that doesn't exist but that has a file as a parent directory. Previously this caused esbuild to fail with the error not a directory. Now with this release, esbuild will ignore this bogus path instead of giving an error.

  • Add more names to the global no-side-effect list (#842)

    This release adds almost all known globals from the browser and node to the list of known globals. Membership in this list means accessing the global is assumed to have no side effects. That means tree shaking is allowed to remove unused references to these globals. For example, since HTMLElement is now in the known globals list, the following class will now be removed when unused:

    class MyElement extends HTMLElement {
    }

    In addition, membership in this list relaxes ordering constraints for the purposes of minification. It allows esbuild to reorder references to these globals past other expressions. For example, since console.log is now in the known globals list, the following simplification will now be performed during minification:

    // Original
    export default (a) => {
      if (a) console.log(b); else console.log(c)
    }
    
    // Minified (previous release)
    export default (a) => {
      a ? console.log(b) : console.log(c);
    };
    
    // Minified (this release)
    export default (a) => {
      console.log(a ? b : c);
    };

    This transformation is not generally safe because the console.log property access might evaluate code which could potentially change the value of a. This is only considered safe in this instance because console.log is now in the known globals list.

    Note that membership in this list does not say anything about whether the function has side effects when called. It only says that the identifier has no side effects when referenced. So console.log() is still considered to have side effects even though console.log is now considered to be free of side effects.

    The following globals are not on the list and are considered to have side effects:

    • scrollX
    • scrollY
    • innerWidth
    • innerHeight
    • pageXOffset
    • pageYOffset
    • localStorage
    • sessionStorage

    Accessing layout-related properties can trigger a layout and accessing storage-related properties can throw an exception if certain privacy settings are enabled. Both of these behaviors are considered side effects.

  • Fix a TypeScript parser regression (#846)

    Restrictions on array and object destructuring patterns in the previous release introduced a regression where arrays or objects in TypeScript code could fail to parse if they were wrapped in a double layer of parentheses. This was due to the speculative parsing of arrow function arguments. The regression has been fixed.

  • Add the Go-specific cli.ParseServeOptions() API (#834)

    This API is specifically for people trying to emulate esbuild's CLI in Go. It lets you share esbuild's logic of parsing the --serve= and --servedir= flags. Use it like this:

    serveOptions, args, err := cli.ParseServeOptions([]string{
      "--serve=8000",
    })
    buildOptions, err := cli.ParseBuildOptions(args)
    result := api.Serve(serveOptions, buildOptions)