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

Cannot minify easily because of a getter with side-effect #55

Open
jaubourg opened this issue Feb 2, 2019 · 1 comment
Open

Cannot minify easily because of a getter with side-effect #55

jaubourg opened this issue Feb 2, 2019 · 1 comment

Comments

@jaubourg
Copy link

jaubourg commented Feb 2, 2019

I was minifying a project with a package depending on node-bindings and the resulting code ended up throwing an exception regarding some path not being a string.

I pinpointed the problem in getRoot which led to the realization that getFileName was returning undefined. Finally, I spotted the culprit: dummy.stack (https://github.com/TooTallNate/node-bindings/blob/master/bindings.js#L168).

Most minifiers will remove code with no side effect, just like getting a property of an object while seemingly not having any use for it.

Since I use uglify-es, I'm able to set the pure_getters compress option to false, which instructs the minifier to be extra-conservative regarding object property accesses.

I dunno if this is something you'd like to "fix" but I thought people should know in case they encounter the same issue.

@thisTom
Copy link

thisTom commented Aug 27, 2019

I was minifying a project with a package depending on node-bindings and the resulting code ended up throwing an exception regarding some path not being a string.

I pinpointed the problem in getRoot which led to the realization that getFileName was returning undefined. Finally, I spotted the culprit: dummy.stack (https://github.com/TooTallNate/node-bindings/blob/master/bindings.js#L168).

Most minifiers will remove code with no side effect, just like getting a property of an object while seemingly not having any use for it.

Since I use uglify-es, I'm able to set the pure_getters compress option to false, which instructs the minifier to be extra-conservative regarding object property accesses.

I dunno if this is something you'd like to "fix" but I thought people should know in case they encounter the same issue.

thank you for this , this problem Trouble me whole week!

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