{"name":"detective-amd","version":"6.1.0","keywords":["amd","detective","dependencies","ast","static analysis","requirejs","jsx","module"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","_id":"detective-amd@6.1.0","maintainers":[{"name":"pahen","email":"patrik.henningsson@gmail.com"},{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"homepage":"https://github.com/dependents/node-detective-amd","bugs":{"url":"https://github.com/dependents/node-detective-amd/issues"},"xo":{"rules":{"curly":["error","multi-line"],"comma-dangle":["error","never"],"prefer-template":"error","arrow-body-style":"off","operator-linebreak":["error","after"],"capitalized-comments":"off","object-curly-spacing":["error","always"],"unicorn/prefer-module":"off","space-before-function-paren":["error","never"],"unicorn/prefer-node-protocol":"off","unicorn/explicit-length-check":"off","unicorn/prevent-abbreviations":"off","unicorn/prefer-top-level-await":"off","unicorn/no-anonymous-default-export":"off"},"space":true,"ignores":["test/fixtures/*"]},"bin":{"detective-amd":"bin/cli.js"},"dist":{"shasum":"7ac35f55325af5df974bb0fe4fdcac032719dc31","tarball":"http://registry-npm.ywwl.com/detective-amd/download/detective-amd-6.1.0.tgz","fileCount":5,"integrity":"sha512-fmI6LGMvotqd49QaA3ZYw+q0aGp2yXmMjzIuY6fH9j9YFIXY/73yDhMwhX9cPbhWd+AH06NH1Di/LKOuCH0Ubg==","signatures":[{"sig":"MEYCIQCWoFiuRWymmRnB9VhgZjSsYMZC/NDw77w470agRuBIBgIhANwFx/l8v1Uw+5h7pOpAQ7I7+VTG+na4N1uPiQsGvt42","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10516,"size":4292,"noattachment":false,"key":"/detective-amd/-/detective-amd-6.1.0.tgz"},"main":"index.js","engines":{"node":">=18"},"gitHead":"2884979d7171d826d7f794fb63f48f251c31cc48","scripts":{"fix":"xo --fix","uvu":"uvu test -i fixtures","lint":"xo","test":"npm run lint && npm run uvu","test:ci":"c8 npm run uvu"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"repository":{"url":"git+https://github.com/dependents/node-detective-amd.git","type":"git"},"_npmVersion":"11.12.1","description":"Find all dependencies within a JavaScript file using AMD module syntax","directories":{},"_nodeVersion":"24.15.0","dependencies":{"escodegen":"^2.1.0","ast-module-types":"^6.0.1","node-source-walk":"^7.0.1","get-amd-module-type":"^6.0.2"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^0.60.0","uvu":"^0.5.6"},"_npmOperationalInternal":{"tmp":"tmp/detective-amd_6.1.0_1777135435517_0.048733073773217006","host":"s3://npm-registry-packages-npm-production"},"readme":"# detective-amd\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-detective-amd/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-detective-amd/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/detective-amd?logo=npm&logoColor=fff)](https://www.npmjs.com/package/detective-amd)\n[![npm downloads](https://img.shields.io/npm/dm/detective-amd)](https://www.npmjs.com/package/detective-amd)\n\nReturns a list of dependencies for a given JavaScript file or AST using any of the AMD module syntaxes.\n\n*Inspired by substack/node-detective but built for AMD.*\n\n```sh\nnpm install detective-amd\n```\n\n* Supports JSX code via [node-source-walk](https://github.com/dependents/node-source-walk).\n\n## Usage\n\nLet's say we have the following file definitions:\n\n```js\n\n// a.js\ndefine(['./b', './c'], function (b, c) {\n  console.log(b, c);\n});\n\n// b.js\ndefine({\n  name: 'foo'\n});\n\n// c.js\ndefine(function () {\n  return 'bar';\n});\n\n```\n\nHere's how you can grab the list of dependencies of `a.js` **synchronously**.\n\n### ESM\n\n```js\nimport fs from 'node:fs';\nimport detective from 'detective-amd';\n\nconst srcA = fs.readFileSync('a.js', 'utf8');\n\n// Pass in the source code or an AST (if you've already parsed the file)\nconsole.log(detective(srcA)); // prints ['./b', './c']\n```\n\n### CommonJS\n\n```js\nconst { default: detective } = require('detective-amd');\n```\n\nYou may also (optionally) configure the detective via a second object argument `detective(src, options)` that supports the following options:\n\n* `skipLazyLoaded`: (boolean) whether or not to omit inner requires in the list of extracted dependencies.\n  * Note: this does not affect the REM form since those inner requires are not \"lazily\" fetched.\n\n## Syntax Support\n\n**Supports the 4 forms of AMD module syntax:**\n\n* \"named\": `define('name', [deps], func)`\n* \"dependency list\": `define([deps], func)`\n* \"factory\": `define(func(require))`\n* \"no dependencies\": `define({})`\n\n**Extra forms:**\n\n* \"driver script\" (or entry-point) syntax: `require([deps], func)`\n* \"REM\" (or CommonJS-like) form: `define(function(require, exports, module) {})`.\n\nAlso handles dynamically loaded dependencies (ex: inner requires).\n\n**Supports driver scripts**\n\nYou can also find the dependencies from a script that has a top-level require (an app initialization/driver/entry-point script):\n\n```js\nrequire([\n  './a'\n], function (a) {\n  // My app will get booted up from here\n});\n```\n\n**Expression-based requires**\n\nIf there's a `require` call with a non-literal, non-call-expression argument, an escodegen-generated string representation is included in the dependency list.\n\nFor example, if `a.js` was of the \"factory\" form and contained a dynamic module name using a binary expression:\n\n```js\n// a.js\n\ndefine(function (require) {\n  // Assume str is some variable that gets set to a string dynamically\n  // const str = ...\n\n  const b = require('./' + str);\n  const c = require('./c');\n\n  console.log(b, c);\n});\n```\n\nThe dependency list will be: `[ '\\'./\\' + str', './c' ]`\n\n* Note: if the argument is a function call (e.g. `require(getModule())`), it cannot be statically determined and is omitted from the list.\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1777135435665,"_cnpm_publish_time":1777135435665,"dist-tags":{"latest":"7.0.0"}}