dependency-cruiser
dependency-cruiser copied to clipboard
Feature request: Take the dependencies map from the bundler, and analyze/visualize it
Context
Right now, dependency-cruiser has to do the transpiling and generating the dependencies graph by itself. It's not scalable, and could violate DRY. Think about adding any new alt-JS such as Svelte. Moreover, what about all the preprocessor for assets, such as .css
or .png
(keep in mind a .css
file can import another .css
file). On the other hand, dependencies graph generation is the core business of any bundler, such as https://github.com/rollup/rollup/issues/1250#issuecomment-271924253 or https://webpack.js.org/configuration/stats/#statsdependentmodules
Expected Behavior
workflow: receive source path to analyze --> generating dep-graph --> validate against rules
Current Behavior
workflow: receive dep-graph (in JSON format?) --> validate against tules
Possible Solution
- Unix pipe input
- accept an argument for existing JSON file
Considered alternatives
Life cycle hooks
Hi @truongsinh the more I think about it, the more I like the idea. I don't think the internal extract step is going to be removed soon, but at least having the option of using output from external tools for validation/ visualisation is valuable.
Dependency-cruiser takes roughly these steps: extract bare dependency tree => enrich => report. It's already possible to feed input into the first step (cli: depcruise
) and into the last (cli: depcruise-fmt
). It shouldn't be too hard to cook something to feed input into the second step. The most work will be transforming output from e.g. parcel into a dependency-tree that matches what the extract step emits.
Is there currently a way to combine dependency-cruiser with rollup?
Dependency cruiser is showing a dependency graph but fails to identify branches that would not be there if tree-shaking was used.