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

preserve implicit return values #1522

Merged
merged 1 commit into from
Mar 3, 2017
Merged

Conversation

alexlamsl
Copy link
Collaborator

Things like Angular Expression and Bookmarklet do not specify return, but implicitedly assumes the evaluated value from the final statement to be the return value.

fixes #354
fixes #543
fixes #625
fixes #628
fixes #640
closes #1293

@kzc
Copy link
Contributor

kzc commented Mar 1, 2017

Probably should add a blurb for the new compress option expression to README and bin/uglifyjs --help

@alexlamsl
Copy link
Collaborator Author

Quick Note: this feature teaches uglify-js to recognise "completion" statements in order to insert or remove return from them.

The latter is then reused in drop_side_effect_free() to remove unnecessary returns from IIFEs.

console.log(function(x, y){return 6}(2,3,a(),b()));
console.log(2);
console.log(6);
console.log((a(), b(), 6));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Bookmarklet for instance implicitedly assumes a "completion value" without using `return`.
The `expression` option now supports such use cases.
Optimisations on IIFEs also enhanced.

fixes mishoo#354
fixes mishoo#543
fixes mishoo#625
fixes mishoo#628
fixes mishoo#640
closes mishoo#1293
@alexlamsl alexlamsl changed the title [WIP] preserve implicit return values preserve implicit return values Mar 3, 2017
@alexlamsl alexlamsl merged commit 07accd2 into mishoo:master Mar 3, 2017
@alexlamsl alexlamsl deleted the issue-640 branch March 3, 2017 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment