-
Notifications
You must be signed in to change notification settings - Fork 81
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
Object desctructuring to remove object properties does not work after minification #390
Comments
This is a new one. Its because it doesn't think theyre used as it doesn't properly understand the object destructuring with the spread operator, i.e. the preceeding arguments/destructured variables change what gets The change needs to be in one of the Analysers, can't recall off the top of my head, pull requests welcome |
I found an issue with destructuring objects with default values, haven’t had a chance to enter it yet, but if anyone can give ideas of where to look, I’ll try to take a pass at all if them. I’ve set aside tomorrow (5/9) to try and fix them. |
That would be great, thanks Without going deep into it i cant tell you exactly where, but from memory its to do with how it parses object literals. I cant remember exactly what the problem was, but the parser gets confused between two different notations/types of objects and it needed more than a quick bugfix to deal with it, that part of the parser needed reconsidering/rewriting |
Probably in |
This one is a bit more than I have time for this week, I'll try to come back to it when I have another free day. |
I haven't fixed it. PRs welcome |
Version
1.21.4
Describe the bug
I'm using object desctructuring to remove object properties. For example:
const { avatar, timeline, backup, ...copy } = { ...user };
After this line
copy
object does not haveavatar
,timeline
andbackup
properties.But after minification not used variables
avatar
,timeline
andbackup
are removed. And as a result mycopy
object is identical to originaluser
object. Which is a big problem in my scenario. I tried to setRemoveUnneededCode
settings tofalse
but it didn't work.To Reproduce
Minified output or stack trace
const func=()=>{const n={avatar:Date(),timeline:Date(),backup:Date(),id:123,name:"Roman"},{...copy}=n;return copy};console.log(func())
Excepted output code
const func=()=>{const n={avatar:Date(),timeline:Date(),backup:Date(),id:123,name:"Roman"},{avatar, timeline, backup,...copy}=n;return copy};console.log(func())
The text was updated successfully, but these errors were encountered: