{"id":22646894,"url":"https://github.com/jmsa/dep-forest","last_synced_at":"2026-02-06T00:01:42.192Z","repository":{"id":265983114,"uuid":"897018781","full_name":"Jmsa/dep-forest","owner":"Jmsa","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-02T05:11:43.000Z","size":88,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T02:04:26.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jmsa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-01T21:21:48.000Z","updated_at":"2024-12-02T05:11:47.000Z","dependencies_parsed_at":"2025-04-11T11:17:27.492Z","dependency_job_id":"911f0514-5f94-4a53-87d0-2d4c56bc8c43","html_url":"https://github.com/Jmsa/dep-forest","commit_stats":null,"previous_names":["jmsa/dep-forest"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Jmsa/dep-forest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jmsa%2Fdep-forest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jmsa%2Fdep-forest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jmsa%2Fdep-forest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jmsa%2Fdep-forest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jmsa","download_url":"https://codeload.github.com/Jmsa/dep-forest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jmsa%2Fdep-forest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29140049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T23:14:48.546Z","status":"ssl_error","status_checked_at":"2026-02-05T23:14:35.724Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-09T07:30:54.018Z","updated_at":"2026-02-06T00:01:42.187Z","avatar_url":"https://github.com/Jmsa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dep-Forest 🌲 🌲 🌲\n\n`dep-forest`, aka \"dependency-forest\", is a tool for analyzing and visualizing the module dependencies in your JavaScript or TypeScript projects. Whether you're using ES Modules (`import`) or CommonJS (`require`), `dep-forest` helps you count and track how many dependencies your code relies on, including their nested dependencies.\n\nIts name comes from the fact that we often think of file dependencies as a tree, or in some cases a forest. As the count of dependencies grows, so does the forest 🌲 🌲 🌲 and in many cases we want to know how many trees we're looking at. This is especially true if we start to see performance issues and want to know which files are most heavily relied on or pulled in as a part of an unexpected dependency tree.\n\n\u003e *Note: there are lots of other tools out there that provide similar functionality, but I wanted a lightweight tool that was easy to understand and extend. In the future additional features like visualizations or eslint-plugin integration are likely to be added - though there are no currently planned milestones.*\n\n## Features\n\n- **ESM \u0026 CommonJS Support**: Tracks dependencies for both `import` and `require` statements.\n- **Recursive Dependency Counting**: Calculates the number of direct and indirect dependencies.\n- **TypeScript Support**: Works seamlessly with TypeScript files (`.ts`, `.tsx`).\n- **File System Integration**: Resolves local file imports and `node_modules` dependencies.\n- **Customizable**: Easily extendable to customize how dependencies are handled.\n\n## Installation\n\nYou can install the package via npm or yarn:\n\n| NPM | Yarn |\n| --- | ---- |\n| `npm install --save-dev dep-forest` | `yarn add -D dep-forest` |\n\n## Usage\n\n### CLI Usage\n\n`dep-forest` comes with a command-line interface that allows you to analyze your project files.\n\n```bash\nyarn dep-forest \u003centry-file\u003e\n```\n\nFor example when run against the examples in this repo:\n\n```bash\nyarn dep-forest ./examples/simple.js \n[dep-forest] Total dependencies for /dep-forest/examples/simple.js: 3\n[dep-forest] \u003e\u003e\u003e visited files: Set(2) {\n  '/dep-forest/examples/simple.js',\n  '/dep-forest/examples/simpleUtility.js'\n}\n[dep-forest] \u003e\u003e\u003e dependencies: [\n  'fs',\n  'path',\n  '/dep-forest/examples/simpleUtility.js'\n]\n\n```\n\nAs you can see this prints out a few things:\n\n- total count of dependencies\n- a list of files that were visited\n- a list of dependencies\n\n## Programmatic Usage\n\nYou can also use dep-forest programmatically in your own scripts:\n\n```javascript\nconst { calculateDependencies } = require('dep-forest');\n\nconst filePath = './examples/simple.js'; // Path to your entry file\nconst { dependencyCount, visited, dependencyPaths } = calculateDependencies(filePath);\n\nconsole.log(`Total dependencies for ${filePath}: ${dependencyCount}`);\n```\n\n## Supported File Types\n\n- JavaScript: .js, .mjs, .jsx\n- TypeScript: .ts, .tsx\n\n## Example Files\n\nExample files can be found in the [example](./example) directory. These will be added on to from time to time to showcase new features or bug fixes and are used for testing.\n\n## Contributing\n\nContributions welcome! Feel free to fork the repo, make changes, and submit a pull request. For larger changes, please open an issue first to discuss what you would like to change. Chances are it's all good - but it's always best to discuss before you put in the effort to implement something.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmsa%2Fdep-forest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmsa%2Fdep-forest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmsa%2Fdep-forest/lists"}