github evanw/esbuild v0.11.8

latest releases: v0.20.2, v0.20.1, v0.20.0...
3 years ago
  • Fix hash calculation for code splitting and dynamic imports (#1076)

    The hash included in the file name of each output file is intended to change if and only if anything relevant to the content of that output file changes. It includes:

    • The contents of the file with the paths of other output files omitted
    • The output path of the file the final hash omitted
    • Some information about the input files involved in that output file
    • The contents of the associated source map, if there is one
    • All of the information above for all transitive dependencies found by following import statements

    However, this didn't include dynamic import() expressions due to an oversight. With this release, dynamic import() expressions are now also counted as transitive dependencies. This fixes an issue where the content of an output file could change without its hash also changing. As a side effect of this change, dynamic imports inside output files of other output files are now listed in the metadata file if the metafile setting is enabled.

  • Refactor the internal module graph representation

    This release changes a large amount of code relating to esbuild's internal module graph. The changes are mostly organizational and help consolidate most of the logic around maintaining various module graph invariants into a separate file where it's easier to audit. The Go language doesn't have great abstraction capabilities (e.g. no zero-cost iterators) so the enforcement of this new abstraction is unfortunately done by convention instead of by the compiler, and there is currently still some code that bypasses the abstraction. But it's better than it was before.

    Another relevant change was moving a number of special cases that happened during the tree shaking traversal into the graph itself instead. Previously there were quite a few implicit dependency rules that were checked in specific places, which was hard to follow. Encoding these special case constraints into the graph itself makes the problem easier to reason about and should hopefully make the code more regular and robust.

    Finally, this set of changes brings back full support for the sideEffects annotation in package.json. It was previously disabled when code splitting was active as a temporary measure due to the discovery of some bugs in that scenario. But I believe these bugs have been resolved now that tree shaking and code splitting are done in separate passes (see the previous release for more information).

Don't miss a new esbuild release

NewReleases is sending notifications on new releases.