esbuild 0.16.7
-
Include
fileloader strings in metafile imports (#2731)Bundling a file with the
fileloader copies that file to the output directory and imports a module with the path to the copied file in thedefaultexport. Previously when bundling with thefileloader, there was no reference in the metafile from the JavaScript file containing the path string to the copied file. With this release, there will now be a reference in the metafile in theimportsarray with the kindfile-loader:{ ... "outputs": { "out/image-55CCFTCE.svg": { ... }, "out/entry.js": { "imports": [ + { + "path": "out/image-55CCFTCE.svg", + "kind": "file-loader" + } ], ... } } } -
Fix byte counts in metafile regarding references to other output files (#2071)
Previously files that contained references to other output files had slightly incorrect metadata for the byte counts of input files which contributed to that output file. So for example if
app.jsimportsimage.pngusing the file loader and esbuild generatesout.jsandimage-LSAMBFUD.png, the metadata for how many bytes ofout.jsare fromapp.jswas slightly off (the metadata for the byte count ofout.jswas still correct). The reason is because esbuild substitutes the final paths for references between output files toward the end of the build to handle cyclic references, and the byte counts needed to be adjusted as well during the path substitution. This release fixes these byte counts (specifically thebytesInOutputvalues). -
The alias feature now strips a trailing slash (#2730)
People sometimes add a trailing slash to the name of one of node's built-in modules to force node to import from the file system instead of importing the built-in module. For example, importing
utilimports node's built-in module calledutilbut importingutil/tries to find a package calledutilon the file system. Previously attempting to use esbuild's package alias feature to replace imports toutilwith a specific file would fail because the file path would also gain a trailing slash (e.g. mappingutilto./file.jsturnedutil/into./file.js/). With this release, esbuild will now omit the path suffix if it's a single trailing slash, which should now allow you to successfully apply aliases to these import paths.