{"id":31228068,"url":"https://github.com/canva-public/dependency-tree","last_synced_at":"2025-09-22T05:03:23.927Z","repository":{"id":38376140,"uuid":"355780261","full_name":"canva-public/dependency-tree","owner":"canva-public","description":"Tool to generate a dependency graph from a given set of files/directories","archived":true,"fork":false,"pushed_at":"2023-11-29T06:11:08.000Z","size":247,"stargazers_count":17,"open_issues_count":12,"forks_count":2,"subscribers_count":13,"default_branch":"main","last_synced_at":"2024-08-08T18:35:18.963Z","etag":null,"topics":["css","dependencies","dependency-tree","depgraph","gherkin","graph","javascript","typescript"],"latest_commit_sha":null,"homepage":"","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/canva-public.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2021-04-08T05:57:49.000Z","updated_at":"2024-03-11T12:31:22.000Z","dependencies_parsed_at":"2023-02-07T01:00:58.668Z","dependency_job_id":null,"html_url":"https://github.com/canva-public/dependency-tree","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/canva-public/dependency-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canva-public%2Fdependency-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canva-public%2Fdependency-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canva-public%2Fdependency-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canva-public%2Fdependency-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/canva-public","download_url":"https://codeload.github.com/canva-public/dependency-tree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canva-public%2Fdependency-tree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276348330,"owners_count":25626605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["css","dependencies","dependency-tree","depgraph","gherkin","graph","javascript","typescript"],"created_at":"2025-09-22T05:01:52.015Z","updated_at":"2025-09-22T05:03:23.917Z","avatar_url":"https://github.com/canva-public.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# @canva/dependency-tree\n\n[![build](https://github.com/canva-public/dependency-tree/actions/workflows/node.js.yml/badge.svg)](https://github.com/canva-public/dependency-tree/actions/workflows/node.js.yml)\n[![npm](https://img.shields.io/npm/v/@canva/dependency-tree.svg)](https://www.npmjs.com/package/@canva/dependency-tree)\n\nThis package can create a dependency tree from a given set of files/folders.\nThe nodes of the tree are files and the edges are file -\u003e file dependencies.\nThe most common way to express such a dependency between two files is some sort of import statement (`require()`, `import ... from`, `@import`) or a directive.\n\nIt provides an extensible API for file processors to generate this dependency tree and comes with a few of them out of the box:\n\n- CSS (postcss dialect, via [`detective-postcss`](https://www.npmjs.com/package/detective-postcss))\n- Gherkin (`*.feature`, via [`gherkin`](https://www.npmjs.com/package/gherkin))\n- JavaScript (via [`acorn`](https://www.npmjs.com/package/acorn) and [`esquery`](https://www.npmjs.com/package/esquery))\n- TypeScript (via [`typescript`](https://www.npmjs.com/package/typescript))\n- [Directives](./docs/directive.md) (custom comment directives to express cross-file dependencies)\n\nIt has support for custom resolvers using [`enhanced-resolve`](https://www.npmjs.com/package/enhanced-resolve) and dynamic reference transformation.\nIt has built-in file caching and test coverage is ~80%+.\n\n# Usage\n\n```ts\nconst dependencyTree = new DependencyTree(['/path/to/my/dir']);\nconst {\n  missing, // a map from files in any of the given root directories to their (missing) dependencies\n  resolved, // a map from files in any of the given root directories to their dependencies\n} = await dependencyTree.gather();\n\n// we can now get set of (transitive) references to a file\nconst directOrTransitiveReferences = DependencyTree.getReferences(resolved, [\n  '/path/to/my/dir/file.ts',\n]);\n\n// or we can get the set of (transitive) dependencies of a file\nconst directOrTransitiveDependencies = DependencyTree.getDependencies(\n  resolved,\n  ['/path/to/my/dir/file.ts'],\n);\n```\n\n# Use cases\n\n- Visualisation of (epxlicit and implicit) in-code dependencies\n- Identifying build targets that need to be regenerated based on affected code\n\n## Releasing\n\n- Bump the version of `package.json` to a meaningful version for the changes since the last release (we follow semver).\n- To do a dry-run of the release and what would go out in the package you can manually execute the [npm-publish](https://github.com/canva-public/dependency-tree/actions/workflows/npm-publish.yml) workflow on the `main` branch. It will do a dry-run publish (not actually publish the new version).\n- Draft a new release in the github project - please use a tag named `vX.X.X` (where `X.X.X` is the new to-be-releases semver of the package - please add as many detail as possible to the release description.\n- Once you're ready, `Publish` the release. Publishing will trigger the [npm-publish](https://github.com/canva-public/dependency-tree/actions/workflows/npm-publish.yml) workflow on the tag and do the actual publish to npm.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanva-public%2Fdependency-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanva-public%2Fdependency-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanva-public%2Fdependency-tree/lists"}