-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Added JSON output to the cli and webpack plugin #341
Conversation
Hi, thanks for opening a pull request for this I wonder if @th0r has opinions about letting people save the generated chart data as JSON instead of HTML with a new option? This approach taken here seems quite legit to me! |
Glad to hear that! If you will decide to include this functionality and there are any changes needed for it please let me know :) |
Will do :) |
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 it would be good for the ecosystem to have this kind of feature in webpack-bundle-analyzer
If there's something in my review comments that isn't clear, feel free to comment saying so 😊. It's also OK to disagree with my inline comments and reply with an alternative viewpoint 💞
Co-Authored-By: Vesa Laakso <482561+valscion@users.noreply.github.com>
…zer into json-output
Hey @valscion. I've updated the PR according to the comments. Wrote one reply. I wanted to ask about node api (I mean the exposed methods in the entry of the package). At the moment the method to start the server is exposed. Could we also expose the generateReport/generateJSONReport methods there? It would simplify using this package inside other node projects. Also this way we could expose the generation of html from json in a proper way instead of abusing the cli (as I showed here: https://github.com/Gongreg/webpack-bundle-analyzer/pull/1/files) I know that this would expose a lot more of internals than it used to be before, but on the other hand they are already accessible through the cli. |
I'm not yet sold on the idea of exposing the generation of HTML from JSON so I'd rather not delve too deep into that subject here, if that's okay to you Let's get the JSON output format out the door first.
Sorry, I'm running a bit slow today — which file are you referring to here? |
I think that's legacy API and we might even want to get rid of it. We haven't documented its existence in the README. It's been there since I joined maintaining this plugin, so I don't know what the idea behind it is. I'd like to avoid adding any new top-level APIs here outside of the new analyzer mode option. We can of course open a discussion about the top-level API — that discussion would preferably be outside this PR, though, in its own issue |
Sure, Should I create a separate issue for it? For now we will just directly render the ejs you have in the package. |
If you want to continue the conversation about this feature then sure |
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.
The code looks good to me now! Thank you for the contribution
I'll give @th0r a few days to take a look at this PR if he has questions, but if not, I'll try to remember to merge and release this this week 😊
Co-Authored-By: Vesa Laakso <482561+valscion@users.noreply.github.com>
Hey @valscion , any news? :) |
Thanks for the contribution! I'll hopefully remember to make a release next time I'm on my coding laptop Feel free to ping me if I haven't made a release by Wednesday |
This has been released in v3.7.0 |
Issue
This issue can be related to #194.
We would like to use the statistics generated by Webpack Bundle Analyzer to track changes in projects. For that we would like to upload/save the bundle sizes in a database, and json is a lot more flexible format for that.
Tests
I've added a test for the json output.
Next step
There is already possibility to generate html from the given json (you expose ejs file that we can directly use). But I think it would be great to add a way to generate the html from cli, but I can't think of a nice way to do it. This is what I currently have created: https://github.com/Gongreg/webpack-bundle-analyzer/pull/1/files