Releases: evanw/esbuild
v0.8.10
-
Fix parsing of conditional types in TypeScript (#541)
Conditional types in TypeScript take the form
A extends B ? C : D
. Parsing of conditional types in esbuild was incorrect. The?
can only follow anextends
clause but esbuild didn't require theextends
clause, which potentially led to build failures or miscompilation. The parsing for this syntax has been fixed and should now match the behavior of the TypeScript compiler. This fix was contributed by @rtsao. -
Ignore comments for character frequency analysis (#543)
Character frequency analysis is used to derive the order of minified names for better gzip compression. The idea is to prefer using the most-used characters in the non-symbol parts of the document (keywords, strings, etc.) over characters that are less-used or absent. This is a very slight win, and is only approximate based on the input text instead of the output text because otherwise it would require minifying twice.
Right now comments are included in this character frequency histogram. This is not a correctness issue but it does mean that documents with the same code but different comments may be minified to different output files. This release fixes this difference by removing comments from the character frequency histogram.
-
Add an option to ignore tree-shaking annotations (#458)
Tree shaking is the term the JavaScript community uses for dead code elimination, a common compiler optimization that automatically removes unreachable code. Since JavaScript is a dynamic language, identifying unused code is sometimes very difficult for a compiler, so the community has developed certain annotations to help tell compilers what code should be considered unused. Currently there two forms of tree-shaking annotations that esbuild supports: inline
/* @__PURE__ */
comments before function calls and thesideEffects
field inpackage.json
.These annotations can be problematic because the compiler depends completely on developers for accuracy and the annotations are occasionally incorrect. The
sideEffects
field is particularly error-prone because by default it causes all files in your package to be considered dead code if no imports are used. If you add a new file containing side effects and forget to update that field, your package will break when people try to bundle it.This release adds a new flag
--tree-shaking=ignore-annotations
to allow you to bundle code that contains incorrect tree-shaking annotations with esbuild. An example of such code is @tensorflow/tfjs. Ideally the--tree-shaking=ignore-annotations
flag is only a temporary workaround. You should report these issues to the maintainer of the package to get them fixed since they will trip up other people too. -
Add support for absolute
baseUrl
paths intsconfig.json
filesPreviously esbuild always joined the
baseUrl
path to the end of the current directory path. However, if thebaseUrl
was an absolute path, that would end up including the current directory path twice. This situation could arise internally in certain cases involving multipletsconfig.json
files andextends
fields even if thetsconfig.json
files themselves didn't have absolute paths. Absolute paths are now not modified and should work correctly. -
Fix crash for modules that do
module.exports = null
(#532)The code generated by esbuild would crash at run-time if a module overwrote
module.exports
with null or undefined. This has been fixed and no longer crashes.
v0.8.9
-
Add support for the
mips64le
architecture (#523)You should now be able to install esbuild on the
mips64le
architecture. This build target is second-tier as it's not covered by CI, but I tested it in an emulator and it appears to work at the moment. -
Fix for packages with inconsistent side effect markings
Packages can have multiple entry points in their
package.json
file. Two commonly-used ones are specified using the fieldsmain
andmodule
. Packages can also mark files in the package as not having side effects using thesideEffects
field. Some packages have one entry point marked as having side effects and the other entry point as not having side effects. This is arguably a problem with the package itself. However, this caused an issue with esbuild's automatic entry point field selection method where it would incorrectly consider bothmain
andmodule
to not have side effects if one of them was marked as not having side effects. Nowmain
andmodule
will only be considered to not have side effects if the individual file was marked as not having side effects. -
Warn about
import './file'
when./file
was marked as having no side effectsFiles in packages containing
"sideEffects": false
in the enclosingpackage.json
file are intended to be automatically removed from the bundle if they aren't used. However, code containingimport './file'
is likely trying to import that file for a side effect. This is a conflict of intentions so it seems like a good idea to warn about this. It's likely a configuration error by the author of the package. The warning points to the location inpackage.json
that caused this situation. -
Add support for glob-style tests in
sideEffects
arraysThe
sideEffects
field inpackage.json
can optionally contain an array of files that are considered to have side effects. Any file not in that list will be removed if the import isn't used. Webpack supports the*
and?
wildcard characters in these file strings. With this release, esbuild supports these wildcard characters too.