-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Comments
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? |
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.
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 ;) |
@michaelficarra there is, 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 |
@mishoo that's nowhere near sufficient for completion value preservation. Not every program is wrapped in an IIFE. |
@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.
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! 😀 |
But preserving completion value is not just about IIFEs. It's about not changing the completion value of the final statement in the program. |
@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 Edit: s/constant/side-effect-free/ |
Defaults will scramble [IIFEs & program completion values](mishoo/UglifyJS#543), which affect the majority JS I feed into this tool.
Closing in favor of #640. |
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
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
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
Not sure why you'd want to alter code behavior the author added in the first place?
ref: #354
The text was updated successfully, but these errors were encountered: