-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Reduce stats requested at emit and optionally remove from template #825
Conversation
…in template callback
For the Trello team, these changes reduced the HML generation step of our build from 20+ seconds to 3. We'd love to see these changes merged upstream. |
Hey @niftymonkey, instead of a constructor property to prevent the Then the performance hit is only for people using the |
@gregjacobs the issue with attempting to make this property lazy has to do with how the internal template loader works. Take a look at this line: https://github.com/jantimon/html-webpack-plugin/blob/master/lib/loader.js#L46 That line of code writes out function scoped vars to make accessing template params not require another call. Part of the code it generates will include Would love some direction from maintainers on the route they'd like to go. Is this actively maintained @jantimon / @mastilver ? |
@gerges Oh ugh.. Didn't realize it was implemented that way. One way to get around that might be to just surround the template code in a 'module.exports = function (templateParams) {' +
'with(templateParams) {' +
// Execute the lodash template
'return (' + template.source + ')();' +
'}' +
'}'; Although the Might be best to have a plugin option after all EDIT: Never mind on the |
Or another option would be an AST transform of the template source to prepend Maybe more effort than it's worth.. |
@gregjacobs Yeah, that's kinda where we landed. Anything past this did seem a little more effort than it was worth to to solve the problem initially. Again though, as @gerges mentioned, if there's anything the maintainers need to have done before we can get this merged, I'd be happy to oblige. |
@jantimon, @mastilver please merge this PR |
Any chance for a merge on this one @jantimon ? |
What about the following solution: It would allow us to remove it from the template but also allow users who really need it to add it back in |
l’ll close this issue for now - please let me know if the proposed solution might not work. |
Implemented in 3.1.0. Please try |
source: false, | ||
timings: false, | ||
version: false | ||
}; |
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 think this could be simplified according to the docs:
var chunkOnlyConfig = {
all: false,
chunks: true
};
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.
Cool good point! 👍
We will remove the getStats call in #953
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.
Even better 👍. Thanks for your work!
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
At Trello we have been dealing with some build speed issues related to building multiple locale specific HTML files. These issues are similar to what's described here.
After instrumenting this plugin, I found that the majority of the time spent here is in the two
toJson
calls that are done. This change modifies the stats we request in the initialtoJson
call in the emit callback and also provides a constructor property that allows plugin users to opt out of thetoJson
call that is done in the template handler. In our case, we didn't need access to thatwebpack
variable in our template, and therefore did not need the overhead of thetoJson
call.