-
Fix a minification regression with CSS media queries (#4315)
The previous release introduced support for parsing media queries which unintentionally introduced a regression with the removal of duplicate media rules during minification. Specifically the grammar for
@media <media-type> and <media-condition-without-or> { ... }was missing an equality check for the<media-condition-without-or>part, so rules with different suffix clauses in this position would incorrectly compare equal and be deduplicated. This release fixes the regression. -
Update the list of known JavaScript globals (#4310)
This release updates esbuild's internal list of known JavaScript globals. These are globals that are known to not have side-effects when the property is accessed. For example, accessing the global
Arrayproperty is considered to be side-effect free but accessing the globalscrollYproperty can trigger a layout, which is a side-effect. This is used by esbuild's tree-shaking to safely remove unused code that is known to be side-effect free. This update adds the following global properties:From ES2017:
AtomicsSharedArrayBuffer
From ES2020:
BigInt64ArrayBigUint64Array
From ES2021:
FinalizationRegistryWeakRef
From ES2025:
Float16ArrayIterator
Note that this does not indicate that constructing any of these objects is side-effect free, just that accessing the identifier is side-effect free. For example, this now allows esbuild to tree-shake classes that extend from
Iterator:// This can now be tree-shaken by esbuild: class ExampleIterator extends Iterator {}
-
Add support for the new
@view-transitionCSS rule (#4313)With this release, esbuild now has improved support for pretty-printing and minifying the new
@view-transitionrule (which esbuild was previously unaware of):/* Original code */ @view-transition { navigation: auto; types: check; } /* Old output */ @view-transition { navigation: auto; types: check; } /* New output */ @view-transition { navigation: auto; types: check; }
The new view transition feature provides a mechanism for creating animated transitions between documents in a multi-page app. You can read more about view transition rules here.
This change was contributed by @yisibl.
-
Trim CSS rules that will never match
The CSS minifier will now remove rules whose selectors contain
:is()and:where()as those selectors will never match. These selectors can currently be automatically generated by esbuild when you give esbuild nonsensical input such as the following:/* Original code */ div:before { color: green; &.foo { color: red; } } /* Old output (with --supported:nesting=false --minify) */ div:before{color:green}:is().foo{color:red} /* New output (with --supported:nesting=false --minify) */ div:before{color:green}
This input is nonsensical because CSS nesting is (unfortunately) not supported inside of pseudo-elements such as
:before. Currently esbuild generates a rule containing:is()in this case when you tell esbuild to transform nested CSS into non-nested CSS. I think it's reasonable to do that as it sort of helps explain what's going on (or at least indicates that something is wrong in the output). It shouldn't be present in minified code, however, so this release now strips it out.