I guess this behavior is grandfathered, but surprising:
echo 'console.log(foo()); bar();' | uglifyjs -c drop_console
WARN: Dropping side-effect-free statement [-:1,0]
bar();
Expected the output: foo(),bar();
The warning "Dropping side-effect-free statement" is erroneous - the original console.log statement was not side-effect free.
The code in question:
https://github.com/mishoo/UglifyJS2/blob/79b98a9fe87f950607c601a45a3566a46c32f425/lib/compress.js#L2212-L2224
Would have expected the args to console.* functions to be converted to equivalent statements.
A possible fix would be to overload the boolean option of drop_console to take another value to account for side effects. Perhaps something like -c drop_console=2
Another "fix" would be to simply document that drop_console does not account for side effects.
I guess this behavior is grandfathered, but surprising:
Expected the output:
foo(),bar();The warning "Dropping side-effect-free statement" is erroneous - the original console.log statement was not side-effect free.
The code in question:
https://github.com/mishoo/UglifyJS2/blob/79b98a9fe87f950607c601a45a3566a46c32f425/lib/compress.js#L2212-L2224
Would have expected the args to console.* functions to be converted to equivalent statements.
A possible fix would be to overload the boolean option of
drop_consoleto take another value to account for side effects. Perhaps something like-c drop_console=2Another "fix" would be to simply document that
drop_consoledoes not account for side effects.