{"id":17242811,"url":"https://github.com/imcuttle/detect-dep","last_synced_at":"2025-04-14T03:25:58.277Z","repository":{"id":29594153,"uuid":"122162547","full_name":"imcuttle/detect-dep","owner":"imcuttle","description":"Detect the dependiencies of import/require by walking AST","archived":false,"fork":false,"pushed_at":"2023-02-17T09:41:37.000Z","size":2979,"stargazers_count":1,"open_issues_count":21,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T02:33:59.151Z","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/imcuttle.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}},"created_at":"2018-02-20T06:20:32.000Z","updated_at":"2023-02-17T09:27:42.000Z","dependencies_parsed_at":"2024-06-21T17:52:26.217Z","dependency_job_id":"4938c722-9aa3-4b07-8e9f-ea24099090aa","html_url":"https://github.com/imcuttle/detect-dep","commit_stats":{"total_commits":18,"total_committers":4,"mean_commits":4.5,"dds":0.2777777777777778,"last_synced_commit":"4b2172ce9faffe9da1b081524b3cf2af12c3c114"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fdetect-dep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fdetect-dep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fdetect-dep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fdetect-dep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imcuttle","download_url":"https://codeload.github.com/imcuttle/detect-dep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248814750,"owners_count":21165819,"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","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-10-15T06:14:08.427Z","updated_at":"2025-04-14T03:25:58.258Z","avatar_url":"https://github.com/imcuttle.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# detect-dep\n\n[![Build status](https://img.shields.io/travis/imcuttle/detect-dep/master.svg?style=flat-square)](https://travis-ci.org/imcuttle/detect-dep)\n[![Test coverage](https://img.shields.io/codecov/c/github/imcuttle/detect-dep.svg?style=flat-square)](https://codecov.io/github/imcuttle/detect-dep?branch=master)\n[![NPM version](https://img.shields.io/npm/v/detect-dep.svg?style=flat-square)](https://www.npmjs.com/package/detect-dep)\n[![NPM Downloads](https://img.shields.io/npm/dm/detect-dep.svg?style=flat-square\u0026maxAge=43200)](https://www.npmjs.com/package/detect-dep)\n[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://prettier.io/)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)\n\n\u003e Detect the dependencies by walking AST\n\n**Support detecting dynamic import and `require.context`**\n\n## Installation\n\n```bash\nnpm install detect-dep\n# or use yarn\nyarn add detect-dep\n```\n\n## Usage\n\n### Package\n\n```javascript\nimport { detectDep } from 'detect-dep'\nconst dependencies = detectDep('some code' /* opts */)\n```\n\n### Cli\n\n```bash\nnpm i detect-dep -g\ndetect-dep --help\ndetect-dep --version\n```\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### AST\n\n[lib/index.js:101-103](https://github.com/imcuttle/detect-dep/blob/678fe76f32eeb929ea94366371bdf64bb1c0403e/lib/index.js#L53-L59 'Source code on GitHub')\n\n- **See: [Abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree)\n  **\n- **See: [babylon](https://github.com/babel/babel/tree/master/packages/babylon)\n  **\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### detectDep\n\n[lib/index.js:101-103](https://github.com/imcuttle/detect-dep/blob/678fe76f32eeb929ea94366371bdf64bb1c0403e/lib/index.js#L101-L103 'Source code on GitHub')\n\n#### Parameters\n\n- `source` {String|AST}\n- `options` {Object}\n  - `options.esModule` {Boolean}\n    Disable `esExport` `esImport` `dynamicImport` when is falsy (optional, default `true`)\n  - `options.requireEnsure` {Boolean}\n    whether detecting `require.ensure(['./a', 'b'])` or not (optional, default `true`)\n  - `options.requireContext` {Boolean}\n    whether detecting `require.context('./root', false, /\\.jsx?$/)` or not (optional, default `true`)\n  - `options.dynamicImport` {Boolean}\n    whether detecting `import('./foo')` `import('./foo/' + name)` or not (optional, default `true`)\n  - `options.esExport` {Boolean}\n    whether detecting `export xx from 'xxx'` or not (optional, default `true`)\n  - `options.esImport` {Boolean}\n    whether detecting `import ...` or not (optional, default `true`)\n  - `options.requireImport` {Boolean}\n    whether detecting `require('...')` or not (optional, default `true`)\n  - `options.localImport` {Boolean}\n    whether requiring `require('./local/path')` or not (optional, default `true`)\n  - `options.moduleImport` {Boolean}\n    whether requiring `require('path')` or not (optional, default `true`)\n  - `options.extensions` {string\\[]}\n    Which file with matching extension should be detected recursively (optional, default `['.js','.jsx']`)\n  - `options.resolveExtensions` {string\\[]}\n    The resolved path's extensions which are allowed (would be extends options.extensions) (optional, default `Object.keys(require.extensions)`)\n  - `options.from` {String}\n    where is the source come from (filename) (optional, default `''`)\n  - `options.recursive` {boolean}\n    Detecting the source recursively. (optional, default `true`)\n  - `options.resolver` {(source, options) =\u003e string\\[]}\n    The core method for resolving dependencies. (optional, default `require('./resolver')`)\n  - `options.returnAbsolutePath` {boolean}\n    whether returning the local module's absolute path, or use real module id instead. (optional, default `true`)\n\n#### Examples\n\n```javascript\nconst { detectDep } = require('detect-dep')\nconst dependencies = detectDep('some code', {})\n```\n\nReturns **any** dependencies {String\\[]} - dependencies list\n\n### Module\n\n[lib/index.js:204-222](https://github.com/imcuttle/detect-dep/blob/678fe76f32eeb929ea94366371bdf64bb1c0403e/lib/index.js#L178-L184 'Source code on GitHub')\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### tree\n\n[lib/index.js:204-222](https://github.com/imcuttle/detect-dep/blob/678fe76f32eeb929ea94366371bdf64bb1c0403e/lib/index.js#L204-L222 'Source code on GitHub')\n\n#### Parameters\n\n- `path` {string}\n- `options` See `detectDep` (optional, default `{}`)\n\n#### Examples\n\n```javascript\nconst {tree} = require('detect-dep')\nconst moduleTree = tree('/path/to/file')\n\n{\n  id: '/path/to/file',\n  children: [\n    {\n      id: '/path/to/file/b.jsx',\n      children: []\n    }\n  ]\n}\n```\n\nReturns **[Module](#module)**\n\n## Contributing\n\n- Fork it!\n- Create your new branch:  \n  `git checkout -b feature-new` or `git checkout -b fix-which-bug`\n- Start your magic work now\n- Make sure npm test passes\n- Commit your changes:  \n  `git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`\n- Push to the branch: `git push`\n- Submit a pull request :)\n\n## Authors\n\nThis library is written and maintained by imcuttle, \u003ca href=\"mailto:moyuyc95@gmail.com\"\u003emoyuyc95@gmail.com\u003c/a\u003e.\n\n## License\n\nMIT - [imcuttle](https://github.com/imcuttle) 🐟\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fdetect-dep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimcuttle%2Fdetect-dep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fdetect-dep/lists"}