npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

how-dep

v0.0.2

Published

<img title="How-Dep" src="/logo.png" width="380">

Downloads

6

Readme

how-dep is a command line tool that analyzes your TypeScript1 project and tells you which libraries you are most dependent on.

Install

$ yarn global add how-dep
# or npm install -g how-dep

Usage

$ how-dep
97  react         # react is imported 97 times
55  react-i18next # react-i18next is imported 55 times
47  classnames    # etc...
...

By default, how-dep will try to find a tsconfig.json file within the current directory, it will then load the project and analyze each file, looking for import statements. It will count how many times each module (3rd party or a local file) is imported and will output a nice report.

Flags

--lib-name, -l

Looking for a single library? Use this flag, passing the library's name (supports regular expressions) [default: "/.*/"]

$ how-dep -l lodash
# or
$ how-dep -l /lodash.*/ # will also catch lodash.get imports (and similar)

--tsconfig-path, -t

A path to a tsconfig.json file [default: "./tsconfig.json"]

$ how-dep -t ../../tsconfig.json

--all, -a

If set to true, will includes all imports (not just 3rd party libraries) [default: false]

$ how-dep -a
97  react                               # node module
55  react-i18next                       # node module
48  /example/src/hooks/use-current-user # local app module!
...

--full-report, -f

If set to true, will first print out a report of all import occurrences [default: false]

$ how-dep -f -l classnames
/example/src/App.tsx                        # file path
2:import cx from 'classnames';              # import statement within that file

/example/src/components/AvatarWall/index.js # another file path
3:import cx from 'classnames';              # import statement within that file
...

--html, -h

If set to true, will generate an HTML report (example) [default: false]

$ how-dep -h

--merge-similar, -m

If set to false, will treat imports of files within a 3rd party package as a different module (i.e., lodash and lodash/fp will be counted separately) [default: true]

$ how-dep -m

Developing

Clone, run yarn to install dependencies, then yarn link to have the how-dep "binary" linked globally, then:

$ yarn start

Then, after making changes to the code, test them by running how-dep in any one of your projects.

1 - Could run on plain javascript projects as well, as long as you provide a tsconfig.json file