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

have reduce_vars and inline respect top_retain #162

Merged
merged 1 commit into from Nov 20, 2018
Merged

have reduce_vars and inline respect top_retain #162

merged 1 commit into from Nov 20, 2018

Conversation

kzc
Copy link
Contributor

@kzc kzc commented Nov 6, 2018

fixes #161

@kzc
Copy link
Contributor Author

kzc commented Nov 6, 2018

Just noticed that reduce_vars doesn't respect top_retain for regular (non function) variables...

$ echo 'var x=1, y=2; console.log(x, y, x+y);' | terser -c top_retain=y
var y=2;console.log(1,2,3);

PR hasn't addressed that yet.

@kzc
Copy link
Contributor Author

kzc commented Nov 6, 2018

Okay, this PR now has top_retain handling functions, classes and regular variables correctly with reduce_vars. Added extensive tests including variations with classes, let, const and arrow functions. Risk and performance impact to default minify should be minimal as all new logic is gated behind compressor.top_retain.

Will leave as WIP for a bit in the event some other broken scenario comes up.

@kzc kzc changed the title WIP: have inline and reduce_vars respect top_retain have inline and reduce_vars respect top_retain Nov 7, 2018
@kzc
Copy link
Contributor Author

kzc commented Nov 7, 2018

This PR is good to merge.

Also added source map support to test/run-tests.js because errors in ill-formed tests were otherwise completely undecipherable.

@kzc kzc changed the title have inline and reduce_vars respect top_retain have reduce_vars and inline respect top_retain Nov 7, 2018
@opichals
Copy link

opichals commented Nov 7, 2018

@kzc Thank you! Verified the #161 tests are passing with the current version of this PR.

opichals added a commit to opichals/rollup-plugin-espruino-modules that referenced this pull request Nov 7, 2018
@kzc
Copy link
Contributor Author

kzc commented Nov 15, 2018

@fabiosantoscode Feel free to merge.

Between this PR and #166 it's probably worthy of a release.

@fabiosantoscode fabiosantoscode merged commit ad18dba into terser:master Nov 20, 2018
@fabiosantoscode
Copy link
Collaborator

Published 3.10.12

@kzc kzc deleted the t161 branch November 20, 2018 21:28
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

Successfully merging this pull request may close these issues.

Unexpected top_retain/reduce_vars/unused results
3 participants