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
[Feature] Inline identity functions when minifying #907
Comments
This isn't super straightforward to fix because doing this correctly would require inserting at least one more full-AST traversal after the scanning phase but before the linking phase. This would slow esbuild down and would work against the goal of having as few passes as possible for speed. So I'm not planning on having esbuild tackle these kinds of optimizations. At least not at the moment. Another consideration is that the author of Terser is currently exploring a rewrite in Rust which should hopefully alleviate the huge performance impact of running Terser during a build. If that rewrite is successful, it might make less sense for esbuild to do all the work to replicate the advanced optimizations that Terser does if people can just run Terser after running esbuild instead. Another similar request: #290. |
That makes total sense, thank you for the quick and thorough response. As the docs mention, esbuild's minification is definitely within range of the alternatives—was just curious if this would be a quick optimization! Going to close this as it seems out of scope for now. |
I implemented this for |
Hello there! I know minification isn't the core focus of
esbuild
, but one very nice feature ofterser
is identity function inlining (see terser#510.) It would be nice ifesbuild
could optimize these functions away as well, as it's a pretty common pattern.Input
Current output
Desired output
The text was updated successfully, but these errors were encountered: