chore(deps): update dependency esbuild to v0.14.21
This MR contains the following updates:
Package | Type | Update | Change |
---|---|---|---|
esbuild | devDependencies | patch | 0.14.18 -> 0.14.21 |
Release Notes
evanw/esbuild
v0.14.21
-
Handle an additional
browser
map edge case (#2001, #2002)There is a community convention around the
browser
field inpackage.json
that allows remapping import paths within a package when the package is bundled for use within a browser. There isn't a rigorous definition of how it's supposed to work and every bundler implements it differently. The approach esbuild uses is to try to be "maximally compatible" in that if at least one bundler exhibits a particular behavior regarding thebrowser
map that allows a mapping to work, then esbuild also attempts to make that work.I have a collection of test cases for this going here: https://github.com/evanw/package-json-browser-tests. However, I was missing test coverage for the edge case where a package path import in a subdirectory of the package could potentially match a remapping. The "maximally compatible" approach means replicating bugs in Browserify's implementation of the feature where package paths are mistaken for relative paths and are still remapped. Here's a specific example of an edge case that's now handled:
-
entry.js
:require('pkg/sub')
-
node_modules/pkg/package.json
:{ "browser": { "./sub": "./sub/foo.js", "./sub/sub": "./sub/bar.js" } }
-
node_modules/pkg/sub/foo.js
:require('sub')
-
node_modules/pkg/sub/bar.js
:console.log('works')
The import path
sub
inrequire('sub')
is mistaken for a relative path by Browserify due to a bug in Browserify, so Browserify treats it as if it were./sub
instead. This is a Browserify-specific behavior and currently doesn't happen in any other bundler (except for esbuild, which attempts to replicate Browserify's bug).Previously esbuild was incorrectly resolving
./sub
relative to the top-level package directory instead of to the subdirectory in this case, which meant./sub
was incorrectly matching"./sub": "./sub/foo.js"
instead of"./sub/sub": "./sub/bar.js"
. This has been fixed so esbuild can now emulate Browserify's bug correctly in this edge case. -
-
Support for esbuild with Linux on RISC-V 64bit (#2000)
With this release, esbuild now has a published binary executable for the RISC-V 64bit architecture in the
esbuild-linux-riscv64
npm package. This change was contributed by @piggynl.
v0.14.20
-
Fix property mangling and keyword properties (#1998)
Previously enabling property mangling with
--mangle-props=
failed to add a space before property names after a keyword. This bug has been fixed:// Original code class Foo { static foo = { get bar() {} } } // Old output (with --minify --mangle-props=.) class Foo{statics={gett(){}}} // New output (with --minify --mangle-props=.) class Foo{static s={get t(){}}}
v0.14.19
-
Special-case
const
inlining at the top of a scope (#1317, #1981)The minifier now inlines
const
variables (even across modules during bundling) if a certain set of specific requirements are met:- All
const
variables to be inlined are at the top of their scope - That scope doesn't contain any
import
orexport
statements with paths - All constants to be inlined are
null
,undefined
,true
,false
, an integer, or a short real number - Any expression outside of a small list of allowed ones stops constant identification
Practically speaking this basically means that you can trigger this optimization by just putting the constants you want inlined into a separate file (e.g.
constants.js
) and bundling everything together.These specific conditions are present to avoid esbuild unintentionally causing any behavior changes by inlining constants when the variable reference could potentially be evaluated before being declared. It's possible to identify more cases where constants can be inlined but doing so may require complex call graph analysis so it has not been implemented. Although these specific heuristics may change over time, this general approach to constant inlining should continue to work going forward.
Here's an example:
// Original code const bold = 1 << 0; const italic = 1 << 1; const underline = 1 << 2; const font = bold | italic | underline; console.log(font); // Old output (with --minify --bundle) (()=>{var o=1<<0,n=1<<1,c=1<<2,t=o|n|c;console.log(t);})(); // New output (with --minify --bundle) (()=>{console.log(7);})();
- All
Configuration
-
If you want to rebase/retry this MR, click this checkbox.
This MR has been generated by Renovate Bot.