Drop required TypeScript dependency
medikoo opened this issue · comments
In Serverless Framework we started to use dependency-tree
to resolve dependencies tree for Node.js AWS lambdas, still we found out that it increased size of a Framework installation by 70MB, and size of our standalone binary iby 30MB
As we investigated, reason is that typescript
started to be included in a project, when it's not really needed by it.
I believe right approach would be to not list typescript
as a dependency, but require TypeScript to be installed aside (which naturally is the case) if one uses dependency-tree
in context of TypeScript project.
Related issue on our side: serverless/dashboard-plugin#423
Hey @medikoo. Thanks for filing the issue. If you an idea for how to make that work, I'm open to suggestions. I've wanted the plug and play nature since the early days of the project. I feel like peerDependencies could help, but not sure.
Alternatively, this module really only adds recursive traversal using the precinct and filing-cabinet modules. Filing-cabinet is likely the problem since it's pulling in typescript itself. You could assemble a module of the precinct detectives and filing cabinet resolvers that you care about. Maybe that's what the interface for this lib should have been, but it was built to be a single tool to handle frontend dependency tree concerns.
I feel like peerDependencies could help, but not sure.
peerDependencies
still suggest, that's it's a mandatory dependency and not optional, so while not enforcing an install it gives a wrong hint I think.
Alternatively, this module really only adds recursive traversal using the precinct and filing-cabinet modules
Indeed problem is deeper, as precinct
unconditionally depends on packages which detect dependencies in various browser formats and those packages unconditionally depend on various preprocessors (CSS, TypeScript etc)
In such case indeed, it may be hard to refactor this package, so it serves Node.js case cleanly without extra baggage.
Thanks for your thoughts. You'd probably want this module with precinct and filing cabinet inlined, then drop all of the detectives and resolvers you don't need. It's not crazy effort.
Thanks for checking out dependency-tree and for the discussion. Cheers!