Skip to content

Visualizes your webpack module dependencies in an interactive graph from your webpack-stats.json file.

License

Notifications You must be signed in to change notification settings

bskydive/webpack-dep-graph

 
 

Repository files navigation

Webpack Dependency Graph Visualizer

Fixed and working. But, there are some bugs around webpack stat file structure. They will be fixed in v1.4.0, I hope.

What is it

  • webpack stats.json parser/converter for visual/UI dependencies analysis
  • configurable filters: exclude, except, include, max deps count
  • output formats:

TODO

Caveats

  • terminology:
    • webpack module: dependencies, source in graph
    • webpack reason(origin): consumer, destination in graph
  • dependency map calculated only for nodes with dependencies. For the dot format it's ok, but for the graphml bunch of nodes added from the dependencies array
  • see the full path in node data properties(right click)
  • search in nodes, urls, properties
  • Exporting one dependency in multiple files can be confusing
  • Graph node label consist of file name only, so if you see similar names, you can right-click it and check the properties-->data tab to see the full path
  • You can enable edge labeling and coloring to check similar dependencies origins

Examples

Generating graphml and editing it in yEd are the best option for now. Best yEd layouts: circular(alt+shift+c), hierarchical(alt+shift+h).

The graphviz layout renderer seems to be less useful. You can upload the simplified dot file into any graphviz editor and try to play with settings.

graphviz

graphml

Used for yed editor

  • graphml: raw xml

  • Manually applied in yed circular layout: tools-->fit node to label, layout-->circular (alt+shift+c)

  • exclude most frequently used dependencies

    	exclude: ["index", "node_modules", "main", "cache", "webpack", "logger", "profile", "config", "platform", "settings", "popup", "confirm", "analytics", "theme", "error",],
    	excludeExcept: [], includeOnlyDestNode: [], includeOnlySrcNode: [],
    	edgeTypeExclude: ["cjs self exports reference","export imported specifier",],
    • summary: imports: 594; dependencies: 123 nodesPaths: 166 nodes: 168
    • graphml
  • include all

    • deps.config.ts
          exclude: [], excludeExcept: [],
          includeOnlyDestNode: [""], includeOnlySrcNode: [""],
          edgeTypeExclude: ["cjs self exports reference","export imported specifier"],
    • summary: imports: 8623; dependencies: 1630 nodesPaths: 2019 nodes: 2021
  • who use @angular/forms dependencies: exclude node_nodules except angular and include only forms source modules

    • filters:
          filters: {
              exclude: ["node_modules"],
              excludeExcept: ["angular"], includeOnlyDestNode: ["key.ts"], includeOnlySrcNode: ["key.ts"],
          //...
          graphml: {
              showSourceEdgeLabels: false,
              showDestEdgeLabels: true,
  • exclude non project files

    • summary: imports: 1654; dependencies: 195 nodesPaths: 224 nodes: 226
    • deps.config.ts
          exclude: ['cache', 'webpack', 'node_modules'],
          excludeExcept: [], includeOnly: [],

What is it for

  • Refactoring decision making helper
  • addition tool for the code analysis methodic
  • Detect a circular dependency in a large monorepo project.
  • Figure out where the module is being used, imported and exported from.
  • Analyze why webpack cannot tree-shake a particular module or dependency from the chunk.

How to run

  • set the config params
  • optionally use node version manager to choose node@16+
  • execute in console
        nvm i 16 # optionally
        npm i
        cp ${your_project_folder}/stats.json ./webpack-dep-graph/webpack-stats.json
        npm run start
        

Similar projects

  • deps graph with npm and vscode plugin
  • deps diff with query language statoscope
  • without webpack stats.json repo
  • forked from: unmaintained broken draft repo
  • Unmaintained repo
  • Unmaintained repo

About

Visualizes your webpack module dependencies in an interactive graph from your webpack-stats.json file.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 95.4%
  • JavaScript 3.5%
  • Other 1.1%