-
Notifications
You must be signed in to change notification settings - Fork 569
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
fix minifyJS when used outside of Node.js #531
Conversation
I just don't get why we need that custom command to generate it. I'd rather if we kept it official. |
@XhmikosR so when However, when it packages itself for the web, it does not include that file since it uses Node.js libraries. Since |
The old code in As for official version of |
Rebased - but I think I still need to convince @XhmikosR about appending extra code to |
@XhmikosR currently,
|
I have now modify Would it make sense to call the output file |
Sorry for the lack of replies, I was busy :/ Personally, I'd like to keep things as vanilla as possible. The problem I see with your solution is that you require a custom step even for node; this shouldn't be needed. Anyway, whatever @kangax prefers. |
@XhmikosR no worries - we all have day job(s) 😉 Which custom step for Node.js are you referring to here? Do you mean |
Looking through all of this - is If that's the case, why don't we get rid of |
Nope, |
refactor minify{URLs,JS,CSS} to reduce evaluation overheads
remove code duplication in minifyJS()
I think this LGTM so merging. Was |
fix minifyJS when used outside of Node.js
@kangax that's right - Now that I'm expanding on |
// try to get global reference first | ||
var result = global[name]; | ||
if (typeof result === 'undefined' && typeof require === 'function') { | ||
result = require(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't play well with webpack:
WARNING in ./
/html-minifier/src/htmlminifier.js/html-minifier/src/htmlminifier.js 649:15-28
Critical dependencies:
649:15-28 the request of a dependency is an expression
@ ./
And later
webpack:///./~/html-minifier/src ^./.*$:13
return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }());
^
Error: Cannot find module 'relateurl'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have zero idea how webpack
works, so PR welcome 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me have a look at it.
Intermittent failures in online tests is primarily due to missing character statistics reset in
minifyJS()
.Redone the non-Node.js version by referring to the official version, also extracted common logic for
minifyCSS()
andminifyURLs()
so we don't have to reload module and repopulate default option values for every invocation.