Skip to content
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

Run DCE without minify? #3706

Closed
commonuserlol opened this issue Mar 21, 2024 · 4 comments
Closed

Run DCE without minify? #3706

commonuserlol opened this issue Mar 21, 2024 · 4 comments

Comments

@commonuserlol
Copy link

Can esbuild run DCE (dead code elimination) without --minify?
https://esbuild.github.io/try/#dAAwLjIwLjIALS1kZWZpbmU6REVCVUc9dHJ1ZSAtLW1pbmlmeQBpZiAoREVCVUcpIHsKICBjb25zb2xlLmxvZygiZGVidWcgbWVzc2FnZSIpOwp9CmNvbnNvbGUubG9nKCJqdXN0IGEgbWVzc2FnZSIpOw
If you remove --minify DEBUG will be replaced with true

@evanw
Copy link
Owner

evanw commented Mar 21, 2024

I assume that you are asking for a way to get esbuild to unwrap the if statement without inserting the comma operator. Enabling and disabling individual minification transforms like that not something that esbuild can do. There are only three separate flags for minification, which are already documented here: https://esbuild.github.io/api/#minify.

@commonuserlol
Copy link
Author

I mean, can esbuild remove dead code (if loop with false statement) but don't minify script?

@evanw
Copy link
Owner

evanw commented Mar 21, 2024

Not in this case. Without minification enabled, esbuild still does some expression-level simplifications but doesn't do statement-level simplifications. Here are two ways to do that without minification enabled: option 1 and option 2.

@commonuserlol
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants