-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minifier always assumes globals are not changed #3686
Comments
Yes esbuild does this. In particular, esbuild hard-codes some well-known JavaScript globals and assumes some properties about them. For example, one optimization that esbuild does is assuming that accessing Another thing that was added recently is that properties of the
Yes, there likely are. JavaScript minification is very complex and esbuild is also very complex. For example, esbuild's optimizer doesn't currently do fixed-point iteration (it instead has a fixed, minimal number of passes) so getting certain minification optimizations to happen can sometimes require knowledge about how esbuild's internal optimizations work. These limitations also change over time. But I didn't intend for that section of the documentation to be a deep dive into the internal details of esbuild's optimizer. |
I have added documentation about these types of assumptions to the minify considerations docs. I'm closing this issue as it's now documented. |
Currently minifier aggressively converts some expression to string value, but it depends on some global methods like
Object.prototype.toString
,Array.prototype.join
.The code below, which is not minified in terser without
unsafe
option, is converted in esbuild with--minify
option.converts to:
which is unsafe when some expression (like
delete Array.prototype.join
) appends.So my question is:
Thanks :)
The text was updated successfully, but these errors were encountered: