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

default negate-iife=false please #543

Closed
tomByrer opened this issue Sep 7, 2014 · 8 comments · Fixed by #1522
Closed

default negate-iife=false please #543

tomByrer opened this issue Sep 7, 2014 · 8 comments · Fixed by #1522

Comments

@tomByrer
Copy link

tomByrer commented Sep 7, 2014

Not sure why you'd want to alter code behavior the author added in the first place?
ref: #354

@michaelficarra
Copy link
Contributor

Program completion value is almost never used. esmangle also defaults to not preserving program completion value. 👎.

aside: Is there an option to preserve program completion value in uglifyjs?

@tomByrer
Copy link
Author

Closure keeps IIFEs as-is. Most of the code I compress is not mine, & there either no tests or I don't have time to install & run them. I think many others are in the same situation.

My use case is compressing files before I host them on jsDelivr free CDN. So I prefer to keep code close as authors published it, just smaller.

Program completion value is almost never used.

That may be true. So @michaelficarra if you'd like to make & test a PR everytime I find a program completion in the wild, I can ping you! But I suspect you are good at keeping yourself busy also ;)

@mishoo
Copy link
Owner

mishoo commented Sep 12, 2014

@michaelficarra there is, -c negate_iife=false.

To be honest, this transformation doesn't bring much to the table. The size savings are probably negligible, we could make it off by default.

However, @tomByrer — why don't you simply pass negate_iife=false in your build scripts?

@michaelficarra
Copy link
Contributor

@mishoo that's nowhere near sufficient for completion value preservation. Not every program is wrapped in an IIFE.

@tomByrer
Copy link
Author

@mishoo I don't use build scripts for alot of my compression. I often use online UglifyJS before uploading to the CDN for those rare projects that don't provide minified version. Perhaps I could just fork it & hardcode the flag myself, but I see others don't like that surprise either.

Not every program is wrapped in an IIFE.

Very true! I think I have to deal with more IIFE usage than you. Since jsDelivr only hosts front-end code (1/3 are of the ~1200 projects we host are jQuery plugins), I'll see alot more IIFEs than a CoffeeScript guru like you! 😀
A few even lead with a ; & their concern is well-founded since we do sever-side concocting.

@michaelficarra
Copy link
Contributor

But preserving completion value is not just about IIFEs. It's about not changing the completion value of the final statement in the program.

@mishoo
Copy link
Owner

mishoo commented Sep 15, 2014

@michaelficarra Indeed. Then nope, we don't have an option for it. Other than negating IIFE-s, the one thing that could affect final value is discarding constant side-effect-free ExpressionStatement-s. I could add an option for it if there's sufficient interest (I personally don't see the point though).

Edit: s/constant/side-effect-free/

tomByrer added a commit to tomByrer/UglifyJS-online that referenced this issue Sep 28, 2014
Defaults will scramble [IIFEs & program completion values](mishoo/UglifyJS#543), which affect the majority JS I feed into this tool.
@rvanvelzen
Copy link
Collaborator

Closing in favor of #640.

alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Mar 1, 2017
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 mishoo#354
fixes mishoo#543
fixes mishoo#625
fixes mishoo#628
fixes mishoo#640
closes mishoo#1293
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Mar 2, 2017
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 added a commit to alexlamsl/UglifyJS that referenced this issue Mar 3, 2017
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 added a commit that referenced this issue Mar 3, 2017
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 #354
fixes #543
fixes #625
fixes #628
fixes #640
closes #1293
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 a pull request may close this issue.

4 participants