webpack-bundle-analyzer icon indicating copy to clipboard operation
webpack-bundle-analyzer copied to clipboard

Add support for reading from STDIN rather than a file

Open dancrumb opened this issue 7 years ago • 3 comments

Issue description

The pattern:

webpack --profile --json > stats.json
webpack-bundle-analyzer bundle/output/path/stats.json

is a little un-*nix.

What would be nicer would be something like

webpack --profile --json | webpack-bundle-analyzer -

When I have some time, I'd be happy to create a PR for this.

dancrumb avatar Apr 11 '18 16:04 dancrumb

Hi there! Thanks for the feature suggestion ☺️

The problem is that we also need the bundled contents from the filesystem. Otherwise we'd only be able to visualize the stat size, which isn't really satisfying.

Thank you for offering to create this kind of PR, but I think it might be out of scope of this library. What do you think, @th0r?

valscion avatar Apr 12 '18 07:04 valscion

Well, I won't mind a PR introducing this feature but with a note in the docs that "in this case you won't see parsed and gzipped sizes".

th0r avatar Apr 12 '18 08:04 th0r

@dancrumb You can use the <() operator right now if your shell supports it:

webpack-bundle-analyzer <(webpack --profile --json)

It's not completely satisfying (as predicted by @th0r and @valscion). Here is the message:

Error parsing bundle asset "/dev/fd/main.cc2aacef761dbe6fd147.bundle.js": no such file

No bundles were parsed. Analyzer will show only original module sizes from stats file.
Screen Shot 2020-04-16 at 9 37 33 AM

antialias avatar Apr 16 '20 16:04 antialias

Probably time to close this, right?

dancrumb avatar Dec 07 '22 00:12 dancrumb

Yeah you can close this if you feel like it 😌 we still don't support reading from STDIN but we're not doing this feature ourselves, either.

valscion avatar Dec 07 '22 07:12 valscion