You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] pure_getters: false still removes optional property access #1632
Please note that this could be a getter with side effects. Removing it changes the program logic. Exactly that happens in my case and that’s how I found the bug. Please consider reopening as this indeed is a problem. The minifier should not change program logic.
@fabiosantoscode - I believe pure_getters being set to true does the opposite. And trying it in the REPL confirms it. this.foo?.bar; becomes empty - i.e. it's completely removed. Perhaps you meant side_effects: false?
changed the title [-][Bug] terser removes optional-chaining in statements[/-][+][Bug] pure_getters: false still removes optional property access[/+]on Jul 26, 2025
Activity
fabiosantoscode commentedon Jul 23, 2025
The value of that property is unused. If it's used somewhere, the property access will be retained.
For example:
console.log(this.foo?.bar)The incomplete
this.fooremains, becausethismight be undefined, and Terser doesn't remove code that might crash.boris-petrov commentedon Jul 23, 2025
fabiosantoscode commentedon Jul 23, 2025
I see! In that case, set the compress option
pure_getterstotrue. When set to true, it doesn't remove unused property access.boris-petrov commentedon Jul 25, 2025
@fabiosantoscode - I believe
pure_gettersbeing set totruedoes the opposite. And trying it in the REPL confirms it.this.foo?.bar;becomes empty - i.e. it's completely removed. Perhaps you meantside_effects: false?fabiosantoscode commentedon Jul 26, 2025
I meant
pure_getters: falsebecause your getter isn't pure. But, it appears that it doesn't do what we would expect.[-][Bug] terser removes optional-chaining in statements[/-][+][Bug] pure_getters: false still removes optional property access[/+]