{"_id":"module-deps-sortable","_rev":"4132988","name":"module-deps-sortable","description":"walk the dependency graph to generate json output that can be fed into browser-pack","dist-tags":{"latest":"5.0.3"},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"time":{"modified":"2026-03-01T18:41:14.000Z","created":"2016-04-27T20:59:36.658Z","5.0.3":"2021-03-13T16:37:33.401Z","5.0.2":"2021-03-02T01:36:15.819Z","5.0.1":"2020-10-24T20:40:55.511Z","5.0.0":"2018-09-21T06:08:24.154Z","4.0.6":"2016-04-29T21:51:24.484Z","4.0.5":"2016-04-27T20:59:36.658Z"},"users":{},"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"repository":{"type":"git","url":"git://github.com/tmcw/module-deps.git"},"versions":{"5.0.3":{"name":"module-deps-sortable","version":"5.0.3","description":"walk the dependency graph to generate json output that can be fed into browser-pack","main":"index.js","bin":{"module-deps":"bin/cmd.js"},"dependencies":{"JSONStream":"^1.0.3","browser-resolve":"^1.7.0","cached-path-relative":"^1.0.0","concat-stream":"~1.5.0","defined":"^1.0.0","detective":"^5.2.0","duplexer2":"^0.1.2","inherits":"^2.0.1","konan":"^2.1.1","readable-stream":"^2.0.2","resolve":"^1.1.3","standard-version":"^9.0.0","stream-combiner2":"^1.1.1","subarg":"^1.0.0","through2":"^2.0.0","xtend":"^4.0.0"},"devDependencies":{"browser-pack":"^5.0.0","tap":"^14.11.0"},"scripts":{"test":"tap test/*.js","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/tmcw/module-deps.git"},"homepage":"https://github.com/tmcw/module-deps","keywords":["dependency","graph","browser","require","module","exports","json"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"engines":{"node":">= 0.6"},"license":"MIT","gitHead":"563eba2637ea410e00b2f6af4ff54c7a4f2eb488","bugs":{"url":"https://github.com/tmcw/module-deps/issues"},"_id":"module-deps-sortable@5.0.3","_nodeVersion":"14.15.0","_npmVersion":"6.14.8","dist":{"shasum":"e640e7450e0869f4ae8e03437665ca2a8a28f843","size":18388,"noattachment":false,"key":"/module-deps-sortable/-/module-deps-sortable-5.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/module-deps-sortable/download/module-deps-sortable-5.0.3.tgz"},"_npmUser":{"name":"tmcw","email":"tom@macwright.com"},"directories":{},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-deps-sortable_5.0.3_1615653453207_0.043138593117057145"},"_hasShrinkwrap":false,"publish_time":1615653453401,"_cnpm_publish_time":1615653453401,"_cnpmcore_publish_time":"2021-12-16T14:44:56.719Z"},"5.0.2":{"name":"module-deps-sortable","version":"5.0.2","description":"walk the dependency graph to generate json output that can be fed into browser-pack","main":"index.js","bin":{"module-deps":"bin/cmd.js"},"dependencies":{"browser-resolve":"^1.7.0","cached-path-relative":"^1.0.0","concat-stream":"~1.5.0","defined":"^1.0.0","duplexer2":"^0.1.2","inherits":"^2.0.1","JSONStream":"^1.0.3","konan":"^2.1.1","readable-stream":"^2.0.2","resolve":"^1.1.3","standard-version":"^9.0.0","stream-combiner2":"^1.1.1","subarg":"^1.0.0","through2":"^2.0.0","xtend":"^4.0.0"},"devDependencies":{"browser-pack":"^5.0.0","tap":"^14.10.8"},"scripts":{"test":"tap test/*.js","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/tmcw/module-deps.git"},"homepage":"https://github.com/tmcw/module-deps","keywords":["dependency","graph","browser","require","module","exports","json"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"engines":{"node":">= 0.6"},"license":"MIT","gitHead":"c80a7a2dd48a5aeece4ea5e0caddb66536b978ff","bugs":{"url":"https://github.com/tmcw/module-deps/issues"},"_id":"module-deps-sortable@5.0.2","_nodeVersion":"14.15.0","_npmVersion":"6.14.8","dist":{"shasum":"5b71ba69cebcb978cc1aefd6c08bd5d345db9b10","size":17553,"noattachment":false,"key":"/module-deps-sortable/-/module-deps-sortable-5.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/module-deps-sortable/download/module-deps-sortable-5.0.2.tgz"},"_npmUser":{"name":"tmcw","email":"tom@macwright.com"},"directories":{},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-deps-sortable_5.0.2_1614648975637_0.8061776616017999"},"_hasShrinkwrap":false,"publish_time":1614648975819,"_cnpm_publish_time":1614648975819,"_cnpmcore_publish_time":"2021-12-16T14:44:56.910Z"},"5.0.1":{"name":"module-deps-sortable","version":"5.0.1","description":"walk the dependency graph to generate json output that can be fed into browser-pack","main":"index.js","bin":{"module-deps":"bin/cmd.js"},"dependencies":{"JSONStream":"^1.0.3","browser-resolve":"^1.7.0","cached-path-relative":"^1.0.0","concat-stream":"~1.5.0","defined":"^1.0.0","detective":"^5.2.0","duplexer2":"^0.1.2","inherits":"^2.0.1","readable-stream":"^2.0.2","resolve":"^1.1.3","standard-version":"^9.0.0","stream-combiner2":"^1.1.1","subarg":"^1.0.0","through2":"^2.0.0","xtend":"^4.0.0"},"devDependencies":{"browser-pack":"^5.0.0","tap":"^14.10.8"},"scripts":{"test":"tap test/*.js","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/substack/module-deps.git"},"homepage":"https://github.com/substack/module-deps","keywords":["dependency","graph","browser","require","module","exports","json"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"engines":{"node":">= 0.6"},"license":"MIT","gitHead":"9ab700671ff55b0843da9e689ebd27011cfc560b","bugs":{"url":"https://github.com/substack/module-deps/issues"},"_id":"module-deps-sortable@5.0.1","_nodeVersion":"13.14.0","_npmVersion":"6.14.8","dist":{"shasum":"b7eec1cb1e556e97db152a78292f768752797615","size":445614,"noattachment":false,"key":"/module-deps-sortable/-/module-deps-sortable-5.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/module-deps-sortable/download/module-deps-sortable-5.0.1.tgz"},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"_npmUser":{"name":"tmcw","email":"tom@macwright.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-deps-sortable_5.0.1_1603572055300_0.08901322784928056"},"_hasShrinkwrap":false,"publish_time":1603572055511,"_cnpm_publish_time":1603572055511,"_cnpmcore_publish_time":"2021-12-16T14:44:57.350Z"},"5.0.0":{"name":"module-deps-sortable","version":"5.0.0","description":"walk the dependency graph to generate json output that can be fed into browser-pack","main":"index.js","bin":{"module-deps":"bin/cmd.js"},"dependencies":{"JSONStream":"^1.0.3","browser-resolve":"^1.7.0","cached-path-relative":"^1.0.0","concat-stream":"~1.5.0","defined":"^1.0.0","detective":"^4.0.0","duplexer2":"^0.1.2","inherits":"^2.0.1","readable-stream":"^2.0.2","resolve":"^1.1.3","stream-combiner2":"^1.1.1","subarg":"^1.0.0","through2":"^2.0.0","xtend":"^4.0.0"},"devDependencies":{"browser-pack":"^5.0.0","tap":"^1.0.0"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"git://github.com/substack/module-deps.git"},"homepage":"https://github.com/substack/module-deps","keywords":["dependency","graph","browser","require","module","exports","json"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"engines":{"node":">= 0.6"},"license":"MIT","gitHead":"efc161710ca97152b8b32dd58343396319a578ef","bugs":{"url":"https://github.com/substack/module-deps/issues"},"_id":"module-deps-sortable@5.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.8.0","_npmUser":{"name":"tmcw","email":"tom@macwright.org"},"dist":{"shasum":"99db5bb08f7eab55e4c31f6b7c722c6a2144ba74","size":30815,"noattachment":false,"key":"/module-deps-sortable/-/module-deps-sortable-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/module-deps-sortable/download/module-deps-sortable-5.0.0.tgz"},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-deps-sortable_5.0.0_1537510104002_0.54901482860124"},"_hasShrinkwrap":false,"publish_time":1537510104154,"_cnpm_publish_time":1537510104154,"_cnpmcore_publish_time":"2021-12-16T14:44:57.591Z"},"4.0.6":{"name":"module-deps-sortable","version":"4.0.6","description":"walk the dependency graph to generate json output that can be fed into browser-pack","main":"index.js","bin":{"module-deps":"bin/cmd.js"},"dependencies":{"JSONStream":"^1.0.3","browser-resolve":"^1.7.0","concat-stream":"~1.5.0","defined":"^1.0.0","detective":"^4.0.0","duplexer2":"^0.1.2","inherits":"^2.0.1","parents":"^1.0.0","readable-stream":"^2.0.2","resolve":"^1.1.3","stream-combiner2":"^1.1.1","subarg":"^1.0.0","through2":"^2.0.0","xtend":"^4.0.0"},"devDependencies":{"tap":"^1.0.0","browser-pack":"^5.0.0"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"git://github.com/substack/module-deps.git"},"homepage":"https://github.com/substack/module-deps","keywords":["dependency","graph","browser","require","module","exports","json"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"engines":{"node":">= 0.6"},"license":"MIT","gitHead":"a15fd4cf06e5bca134313ae4809359ad80952ff6","bugs":{"url":"https://github.com/substack/module-deps/issues"},"_id":"module-deps-sortable@4.0.6","_shasum":"1251a4ba2c44a92df6989bd029da121a4f2109b0","_from":".","_npmVersion":"3.8.6","_nodeVersion":"5.11.0","_npmUser":{"name":"tmcw","email":"tom@macwright.org"},"dist":{"shasum":"1251a4ba2c44a92df6989bd029da121a4f2109b0","size":16532,"noattachment":false,"key":"/module-deps-sortable/-/module-deps-sortable-4.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/module-deps-sortable/download/module-deps-sortable-4.0.6.tgz"},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/module-deps-sortable-4.0.6.tgz_1461966682222_0.2043770090676844"},"directories":{},"publish_time":1461966684484,"_hasShrinkwrap":false,"_cnpm_publish_time":1461966684484,"_cnpmcore_publish_time":"2021-12-16T14:44:57.847Z"},"4.0.5":{"name":"module-deps-sortable","version":"4.0.5","description":"walk the dependency graph to generate json output that can be fed into browser-pack","main":"index.js","bin":{"module-deps":"bin/cmd.js"},"dependencies":{"JSONStream":"^1.0.3","browser-resolve":"^1.7.0","concat-stream":"~1.5.0","defined":"^1.0.0","detective":"^4.0.0","duplexer2":"^0.1.2","inherits":"^2.0.1","parents":"^1.0.0","readable-stream":"^2.0.2","resolve":"^1.1.3","stream-combiner2":"^1.1.1","subarg":"^1.0.0","through2":"^2.0.0","xtend":"^4.0.0"},"devDependencies":{"tap":"^1.0.0","browser-pack":"^5.0.0"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"git://github.com/substack/module-deps.git"},"homepage":"https://github.com/substack/module-deps","keywords":["dependency","graph","browser","require","module","exports","json"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"engines":{"node":">= 0.6"},"license":"MIT","gitHead":"fd24b50d1940a02d56bafa24bd47bcfbaa4d6ee7","bugs":{"url":"https://github.com/substack/module-deps/issues"},"_id":"module-deps-sortable@4.0.5","_shasum":"b755dd5d624b96f9806f0501db2fff8335ccb3c8","_from":".","_npmVersion":"3.8.6","_nodeVersion":"6.0.0","_npmUser":{"name":"tmcw","email":"tom@macwright.org"},"dist":{"shasum":"b755dd5d624b96f9806f0501db2fff8335ccb3c8","size":16000,"noattachment":false,"key":"/module-deps-sortable/-/module-deps-sortable-4.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/module-deps-sortable/download/module-deps-sortable-4.0.5.tgz"},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/module-deps-sortable-4.0.5.tgz_1461790774154_0.8594808063935488"},"directories":{},"publish_time":1461790776658,"_hasShrinkwrap":false,"_cnpm_publish_time":1461790776658,"_cnpmcore_publish_time":"2021-12-16T14:44:58.103Z"}},"readme":"# module-deps\n\nwalk the dependency graph to generate json output that can be fed into\n[browser-pack](https://github.com/substack/browser-pack)\n\n# example\n\n``` js\nvar mdeps = require('module-deps');\nvar JSONStream = require('JSONStream');\n\nvar md = mdeps();\nmd.pipe(JSONStream.stringify()).pipe(process.stdout);\nmd.end({ file: __dirname + '/files/main.js' });\n```\n\noutput:\n\n```\n$ node example/deps.js\n[\n{\"id\":\"/Users/substack/src/module-deps/example/files/bar.js\",\"source\":\"module.exports = function (n) {\\n    return n * 100;\\n};\\n\",\"deps\":{},\"file\":\"/Users/substack/src/module-deps/example/files/bar.js\",\"sortKey\":\"!/Users/substack/src/module-deps/example/files/main.js:00000000!/Users/substack/src/module-deps/example/files/foo.js:00000000!/Users/substack/src/module-deps/example/files/bar.js\"}\n,\n{\"id\":\"/Users/substack/src/module-deps/example/files/foo.js\",\"source\":\"var bar = require('./bar');\\n\\nmodule.exports = function (n) {\\n    return n * 111 + bar(n);\\n};\\n\",\"deps\":{\"./bar\":\"/Users/substack/src/module-deps/example/files/bar.js\"},\"file\":\"/Users/substack/src/module-deps/example/files/foo.js\",\"sortKey\":\"!/Users/substack/src/module-deps/example/files/main.js:00000000!/Users/substack/src/module-deps/example/files/foo.js\"}\n,\n{\"file\":\"/Users/substack/src/module-deps/example/files/main.js\",\"id\":\"/Users/substack/src/module-deps/example/files/main.js\",\"source\":\"var foo = require('./foo');\\nconsole.log('main: ' + foo(5));\\n\",\"deps\":{\"./foo\":\"/Users/substack/src/module-deps/example/files/foo.js\"},\"sortKey\":\"!/Users/substack/src/module-deps/example/files/main.js\",\"entry\":true}\n]\n```\n\nand you can feed this json data into\n[browser-pack](https://github.com/substack/browser-pack):\n\n```\n$ node example/deps.js | browser-pack | node\nmain: 1055\n```\n\n# usage\n\n```\nusage: module-deps [files]\n\n  generate json output from each entry file\n\n```\n\n# methods\n\n``` js\nvar mdeps = require('module-deps')\n```\n\n## var d = mdeps(opts={})\n\nReturn an object transform stream `d` that expects entry filenames or\n`{ id: ..., file: ... }` objects as input and produces objects for every\ndependency from a recursive module traversal as output.\n\nEach file in `files` can be a string filename or a stream.\n\nOptionally pass in some `opts`:\n\n* `opts.transform` - a string or array of string transforms (see below)\n\n* `opts.transformKey` - an array path of strings showing where to look in the\npackage.json for source transformations. If falsy, don't look at the\npackage.json at all.\n\n* `opts.resolve` - custom resolve function using the\n`opts.resolve(id, parent, cb)` signature that\n[browser-resolve](https://github.com/shtylman/node-browser-resolve) has\n\n* `opts.filter` - a function (id) to skip resolution of some module `id` strings.\nIf defined, `opts.filter(id)` should return truthy for all the ids to include\nand falsey for all the ids to skip.\n\n* `opts.postFilter` - a function (id, file, pkg) that gets called after `id` has\nbeen resolved. Return false to skip this file.\n\n* `opts.packageFilter` - transform the parsed package.json contents before using\nthe values. `opts.packageFilter(pkg, dir)` should return the new `pkg` object to\nuse.\n\n* `opts.noParse` - an array of absolute paths to not parse for dependencies. Use\nthis for large dependencies like jquery or threejs which take forever to parse.\n\n* `opts.cache` - an object mapping filenames to file objects to skip costly io\n\n* `opts.packageCache` - an object mapping filenames to their parent package.json\ncontents for browser fields, main entries, and transforms\n\n* `opts.fileCache` - an object mapping filenames to raw source to avoid reading\nfrom disk.\n\n* `opts.paths` - array of global paths to search. Defaults to splitting on `':'`\nin `process.env.NODE_PATH`\n\n* `opts.ignoreMissing` - ignore files that failed to resolve\n\n# input objects\n\nInput objects should be string filenames or objects with these parameters:\n\n* `row.file` - filename\n* `row.expose` - name to be exposed as\n* `row.noparse` when true, don't parse the file contents for dependencies\n\nor objects can specify transforms:\n\n* `row.transform` - string name, path, or function\n* `row.options` - transform options as an object\n* `row.global` - boolean, whether the transform is global\n\n# events\n\n## d.on('transform', function (tr, file) {})\n\nEvery time a transform is applied to a `file`, a `'transform'` event fires with\nthe instantiated transform stream `tr`.\n\n## d.on('file', function (file) {})\n\nEvery time a file is read, this event fires with the file path.\n\n## d.on('missing', function (id, parent) {})\n\nWhen `opts.ignoreMissing` is enabled, this event fires for each missing package.\n\n## d.on('package', function (pkg) {})\n\nEvery time a package is read, this event fires. The directory name of the\npackage is available in `pkg.__dirname`.\n\n# transforms\n\nmodule-deps can be configured to run source transformations on files before\nparsing them for `require()` calls. These transforms are useful if you want to\ncompile a language like [coffeescript](http://coffeescript.org/) on the fly or\nif you want to load static assets into your bundle by parsing the AST for\n`fs.readFileSync()` calls.\n\nIf the transform is a function, it should take the `file` name as an argument\nand return a through stream that will be written file contents and should output\nthe new transformed file contents.\n\nIf the transform is a string, it is treated as a module name that will resolve\nto a module that is expected to follow this format:\n\n``` js\nvar through = require('through2');\nmodule.exports = function (file) { return through() };\n```\n\nYou don't necessarily need to use the\n[through2](https://github.com/rvagg/through2) module to create a\nreadable/writable filter stream for transforming file contents, but this is an\neasy way to do it.\n\nWhen you call `mdeps()` with an `opts.transform`, the transformations you\nspecify will not be run for any files in node_modules/. This is because modules\nyou include should be self-contained and not need to worry about guarding\nthemselves against transformations that may happen upstream.\n\nModules can apply their own transformations by setting a transformation pipeline\nin their package.json at the `opts.transformKey` path. These transformations\nonly apply to the files directly in the module itself, not to the module's\ndependants nor to its dependencies.\n\n# output objects\n\nThe objects emitted from module-deps include file contents, metadata, and\ndependencies.\n\n* source: the complete source code of the file as a string\n* file: the filename\n* sortKey: a string that consists of the dependency path from root to this\n  file, along with line numbers of the require statements. This makes it possible\n  to sort the results in order written in the source.\n* deps: an object that maps between the string given to the `require` method\n  and the filename it resolves to\n\n## package.json transformKey\n\nTransform keys live at a configurable location in the package.json denoted by\nthe `opts.transformKey` array.\n\nFor a transformKey of `['foo','bar']`, the transformKey can be a single string\n(`\"fff\"`):\n\n``` json\n{\n  \"foo\": {\n    \"bar\": \"fff\"\n  }\n}\n```\n\nor an array of strings (`[\"fff\",\"ggg\"]`):\n\n``` json\n{\n  \"foo\": {\n    \"bar\": [\"fff\",\"ggg\"]\n  }\n}\n```\n\nIf you want to pass options to the transforms, you can use a 2-element array\ninside of the primary array. Here `fff` gets an options object with `{\"x\":3}`\nand `ggg` gets `{\"y\":4}`:\n\n``` json\n{\n  \"foo\": {\n    \"bar\": [[\"fff\",{\"x\":3}],[\"ggg\",{\"y\":4}]]\n  }\n}\n```\n\n# usage\n\n```\nmodule-deps [FILES] OPTIONS\n\n  Generate json output for the entry point FILES.\n\nOPTIONS are:\n\n  -t TRANSFORM  Apply a TRANSFORM.\n  -g TRANSFORM  Apply a global TRANSFORM.\n\n```\n\n# install\n\nWith [npm](http://npmjs.org), to get the module do:\n\n```\nnpm install module-deps\n```\n\nand to get the `module-deps` command do:\n\n```\nnpm install -g module-deps\n```\n\n# license\n\nMIT\n","_attachments":{},"homepage":"https://github.com/tmcw/module-deps","bugs":{"url":"https://github.com/tmcw/module-deps/issues"},"license":"MIT"}