-
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
define and boolean elimination #2063
Comments
No. The external import of |
Ah yes I forgot to add the import. However, it is not the proposal of the issue: the proposal is to remove the useless boolean constant. In other words, instead of emitting: import { assert } from "assert-mod";
function sqrt(x) {
false;
return Math.sqrt(x);
}
export {
sqrt
}; esbuild could emit: import { assert } from "assert-mod";
function sqrt(x) {
return Math.sqrt(x);
}
export {
sqrt
}; Diff between the two versions: import { assert } from "assert-mod";
function sqrt(x) {
- false;
return Math.sqrt(x);
}
export {
sqrt
}; |
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
I would like to thank you again for esbuild and its excellent documentation (including the CHANGELOG).
I use esbuild as the main tool to build my libraries. Usually I have two builds:
In my code I generally extensively use assertions (pre- and post- conditions). I would like to remove these assertions in the production build. The only way I know to achieve it with esbuild is to use a constant such as DEBUG:
and set DEBUG to false (or 0) for the production build:
However, esbuild emits the following code:
Note the apparition of an expression-statement
false;
.Do you think it could be possible to improve a bit the dead-code elimination in order to remove also the boolean constant? The emitted code could be:
Note that I would like to avoid minification to keep a readable code.
Alternative solution
Another solution could be to add a
--drop:assert
.The text was updated successfully, but these errors were encountered: