Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Feature suggestion: Package Dependency Tree #53

Closed
eirikurn opened this issue Feb 17, 2017 · 9 comments
Closed

Feature suggestion: Package Dependency Tree #53

eirikurn opened this issue Feb 17, 2017 · 9 comments

Comments

@eirikurn
Copy link

eirikurn commented Feb 17, 2017

I've created a proof-of-concept package dependency algorithm using the reasons metadata which might make this tool even more useful.

Instead of creating a tree of modules based on their location in the file system, it creates a tree where leafs are modules but non-leaf (folder) nodes are packages and connections are module/package dependencies. This shows more clearly the complete size of installed packages and how they relate.

For shared code, if a package is used in multiple places, it becomes a "shared" package node higher in the tree. If a package contains optional modules used in different places, then it could appear in multiple places in the tree. Example:

react: 103.8 KB - shared by <root>, react-dom & 6 more
react-addons-css-transition-group: 30.7 KB
  react: 30.64 KB (99.8%)
  <self>: 62 B (0.197%)

This example shows 103,8KB of "shared" react code used by two or more packages. However, react-addons-css-transition-group is loading an additional 30,64KB of react code, making the "sum cost" of css-transition-group 30,7KB instead of 62B. This is difficult to figure out with existing analyzers and might make other animation libraries more appealing.

I honestly think this is a life saver when evaluating new project dependencies or when looking for fat dependencies to trim. Some might have a small tree of huge dependencies, others might have a large tree of tiny dependencies, yet others might depend on packages already being used, making the difference a smaller one.

I'm going to try and integrate the algorithm into this project/viewer. At least as a fork for my use, but I think it is very useful to others.

EDIT: Feel free to try the POC running in a fork of webpack-bundle-size-analyzer.

@eirikurn
Copy link
Author

I imagine this would work well with the split analyzer and ui code, a la #32 and #40. It might also be useful for #41.

@basicdays
Copy link

This would be amazing. Just tried out the webpack-bundle-analyzer today and this tool made it immediately obvious some dependency is pulling in all of lodash. We'll have to go code spelunking to figure out which one is doing that or find another tool to report on that. It'd be amazing to have all of that within one tool.

@wmertens
Copy link

wmertens commented Apr 5, 2017 via email

@valscion
Copy link
Member

valscion commented Apr 6, 2017

Yeah an use case such as this one is definitely a thing I want to make possible with #32 and #40.

Too bad that your fork is an entirely different project, so comparing the diff makes no sense.

@Frondor
Copy link

Frondor commented Apr 30, 2018

I don't know if I get the idea, but does it tries to display where is a dependency coming from? I'm trying to tree-shake lodash properly, and I'm using a few lodash/fn functions, but in the analyzer I see a lot of small lodash functions imported... I'd like to know which other packages are importing them. Is that possible with this approach?

@eirikurn
Copy link
Author

eirikurn commented Apr 30, 2018 via email

@yvele
Copy link

yvele commented Feb 18, 2020

Any workaround or external tool to get the dependency tree of a Webpack bundle? 🤔

@wmertens
Copy link

@yvele you can use http://webpack.github.io/analyse/

@yvele
Copy link

yvele commented Feb 19, 2020

@yvele you can use http://webpack.github.io/analyse/

It's not working with my stats.json 🤔

web.js:1 Uncaught TypeError: Cannot read property 'sort' of undefined
    at web.js:1
    at Object.n.load (web.js:1)
    at FileReader.l.onload (15f6448ec2a08f35395d.js:1)

@webpack-contrib webpack-contrib locked and limited conversation to collaborators Feb 23, 2023
@valscion valscion converted this issue into discussion #560 Feb 23, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

6 participants