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
"Minify JavaScript" / UglifyJS fails without reporting error #967
Comments
|
Right, as cited above. The emphasis should be on "fails without error". Or rather "ignores error" without user message. |
It's working as designed. If it cannot parse the JS it will emit it as is. |
Right, again, that was acknowledged in the original issue report:
Silently failing instead of having an error or warning is egregious. I'd like to know what the use case is for a tool to silently fail when passed unsupported input? Precisely we are petitioning for the design to change which would make the tool more reliable & save downstream users lots of wasted time & woes. Is there an actual objection to changing the design? It doesn't seem to make much sense to expend time debating whether this is a feature request vs a bug, if that's your intention, we're just expressing our opinion that the current behavior is not very useful & that changing the behavior would be more useful to us. People will end up with seemingly random unminified output with no idea why, spend lots of time hunting down why, then will end up here & expend your time posting issues.... If the tool outputted a warning then at least users would be cognizant of the implications of adding es6, and would be able to make a deliberate decision to either not use es6 / disable minification intentionally. I would like to know if you are objecting to making a change here, and the reason why? Simply replying with facts that were already stated in the original issue report are not particularly helpful. I think it would be more helpful to outright say that you're not supporting the use case (and if so why), or acknowledge that the current workflow can be improved so that someone can start on a PR? Instead it seems to me like we may be spinning our wheels here without any resolution one way or the other, and I have to wonder to what end. This is a great tool & I while I cannot speak for others, I feel the intention of the community is to make it even greater, not debate semantics. |
Is it possible for |
Actually, you could just use 'terser', which
The uglify-es package is no longer being maintained. |
@danielvaijk How exactly can we use terser with html-minifier? |
@janusz-bb, here's a snippet of a module I wrote for one of my projects. The code belongs to a helper function that minifies HTML content (via html-minifier) rendered by Pug on a server application using Express.
Notice how I plug in Terser in the |
This project appears to be unmaintained now, but a fork has moved to |
I have not tried html-minifier-terser yet because I just learned about it thanks to the post by @gnbl above, but I leave this note here for people having the same nasty problem (html-minifier not reporting uglify-js errors). I have extended @danielvaijk tip to wrap uglify-js in some code to recognize any problems with the to-be-minified code
|
I'm running html-minifier 3.5.14 locally but also tried the current online version http://kangax.github.io/html-minifier/ with my code, which just does not seem to minify the javascript.
I've narrowed down the cause to a
const
declaration:results in
It works when I change it to a plain old
var
.There's a note on SO:
https://stackoverflow.com/a/47440295
However, I don't get an error with my local html-minfier either.
It would be nice if the user would get to see the underlying error message.
It also can't handle default function parameters, `let`, `=>`, etc. . There's a demo at http://lisperator.net/uglifyjs/ which throws errors.
The text was updated successfully, but these errors were encountered: