Hello Gabriel. I want to let you know that discovering this package on /r/javascript
made my day today.
What a terrific (and fast!) tool that I wish I discovered a week ago!
I'm in the middle of trying to write a change detector for a CI/CD pipeline and the functionality I'm looking for is very close to what dep-tree
offers.
Was wondering if you would consider adding another command -- similar to render
-- that could output the dependency tree to JSON format (or even YAML)?
Feature Request Summary
For example, given the following output from render
:
index.tsx
│
├▷../../../../libs/providers/products/products.ts
└▷│../../../../libs/utils/analytics/commonEvents.ts
││
└│▷../../../../libs/providers/_factory.tsx
├▷../../../../libs/utils/analytics/constants.ts
└▷../../../../libs/utils/url.ts
It would be cool to have an option to output something like this to stdout
:
{
/* parent dep, has list of child deps */
"index.tsx": [
/* item plain string means no further child deps */
"../../../../libs/providers/products/products.ts",
/* object means further child deps follow */
{
/* process continues, recursively */
"../../../../libs/utils/analytics/commonEvents.ts": [
/* leaf nodes -- no further sub-deps */
"../../../../libs/providers/_factory.tsx",
"../../../../libs/utils/analytics/constants.ts",
"../../../../libs/utils/url.ts"
]
}
]
}
(This syntax is just a suggestion, not a requirement)
Suggested Interface
This could either be:
- A new command (eg
dep-tree parse ...
)
- An output/format flag on the existing
render
command (eg dep-tree render ... --output=json
)
If we go with option 2, it could either be:
--output=<format>
like kubectl
--json
like Yarn workspace tools
Prior Art
I've evaluated some other options but none of them have the ease-of-operation nor the speed of your package. Here's what I've tried:
@vercel/nft
Node File Trace comes close but:
👎 It has no CLI
👎 It's much slower
👎 It has a strange bug/behaviour where the current working directory changes the output
dependency-cruiser
Dependency Cruiser is very powerful but:
👎 Is much more verbose in output
👎 Harder to use (not as targeted to the exact use-case of dep-tree
👎 Appears unable to cross the package.json
boundaries
dependency-tree
Dependency Tree has more of the same issues:
👎 Is slower
👎 Requires more onerous configuration
👎 inherits bugs from the underlying precinct module
The reason I ask this request of you is because your package already has the following advantages:
✅ speed
✅ correctness
✅ appropriateness to my use-case
✅ punches through package boundaries without issue
And would be perfect if I could get a machine-readable output! 😁
Please let me know if this is something you'd consider adding.
Thanks
Bryce