{"name":"precinct","version":"12.1.3","keywords":["modules","amd","commonjs","es6","sass","less","detective","dependencies"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","_id":"precinct@12.1.3","homepage":"https://github.com/dependents/node-precinct","bugs":{"url":"https://github.com/dependents/node-precinct/issues"},"xo":{"rules":{"curly":["error","multi-line"],"comma-dangle":["error","never"],"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/prevent-abbreviations":"off","unicorn/prefer-top-level-await":"off"},"space":true,"ignores":["test/fixtures/*"]},"bin":{"precinct":"bin/cli.js"},"dist":{"shasum":"cb8542ac2168f1d395aea785eaf183f5d84d3cdb","tarball":"http://registry-npm.ywwl.com/precinct/download/precinct-12.1.3.tgz","fileCount":6,"integrity":"sha512-6zuVmMR89TGHQ0oI2632SjTrqqnhoTkB/AuxQchWNmv5BJXFdUEG86rq7geI41/hX7hGadMJ5em6eQWwpSHK7A==","signatures":[{"sig":"MEYCIQDJXBqf4WxO8V3XMYPTljCrUks4qPzx1uCEC3JIKJd0XgIhAITC16kMyViPX86S1byyqEjPeHcyzWiEJe0uvueOVZ4J","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13334,"size":4919,"noattachment":false,"key":"/precinct/-/precinct-12.1.3.tgz"},"main":"index.js","types":"index.d.ts","engines":{"node":">=18"},"gitHead":"ca03588cd7ba2f1785d5e699e561a444961372f1","scripts":{"fix":"xo --fix","lint":"xo","test":"npm run lint && npm run mocha","mocha":"mocha","test:ci":"c8 npm run mocha"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"repository":{"url":"git+https://github.com/dependents/node-precinct.git","type":"git"},"_npmVersion":"10.8.2","description":"Unleash the detectives","directories":{},"_nodeVersion":"20.18.2","dependencies":{"postcss":"^8.5.1","commander":"^12.1.0","typescript":"^5.7.3","detective-amd":"^6.0.1","detective-cjs":"^6.0.1","detective-es6":"^5.0.1","detective-sass":"^6.0.1","detective-scss":"^5.0.1","detective-vue2":"^2.1.2","detective-stylus":"^5.0.1","node-source-walk":"^7.0.1","detective-postcss":"^7.0.1","module-definition":"^6.0.1","detective-typescript":"^13.0.1","@dependents/detective-less":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^0.60.0","mocha":"^11.1.0","sinon":"^19.0.2","rewire":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/precinct_12.1.3_1738416523840_0.00413452394779279","host":"s3://npm-registry-packages-npm-production"},"readme":"# precinct\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-precinct/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-precinct/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/precinct?logo=npm&logoColor=fff)](https://www.npmjs.com/package/precinct)\n[![npm downloads](http://img.shields.io/npm/dm/precinct)](https://www.npmjs.com/package/precinct)\n\n> Unleash the detectives\n\n```sh\nnpm install precinct\n```\n\nUses the appropriate detective to find the dependencies of a file or its AST.\n\nSupports:\n\n* JavaScript modules: AMD, CommonJS, and ES6\n* TypeScript\n* CSS Preprocessors: Sass, Scss, Stylus, and Less\n* CSS (PostCSS)\n\n## Usage\n\n```js\nconst fs = require('fs');\nconst precinct = require('precinct');\n\nconst content = fs.readFileSync('myFile.js', 'utf8');\n\n// Pass in a file's content or an AST\nconst deps = precinct(content);\n```\n\nYou may pass options (to individual detectives) based on the module type via an optional second object argument `detective(content, options)`, for example:\n\nExample call:\n\n```js\nprecinct(content, {\n  amd: {\n    skipLazyLoaded: true\n  },\n  type: 'amd'\n});\n```\n\n* The supported module type prefixes are: `amd`, `commonjs`, `css`, `es6`, `less`, `sass`, `scss`, `stylus`, `ts`, `tsx`, `vue`.\n\nCurrent options:\n\n* `amd.skipLazyLoaded`: tells the AMD detective to omit lazy-loaded dependencies (i.e., inner requires).\n* `es6.mixedImports`: allows for all dependencies to be fetched from a file that contains both CJS and ES6 imports.\n  * Note: This will work for any file format that contains an ES6 import.\n* `css.url`: tells the CSS detective to include `url()` references to images, fonts, etc.\n\nFinding non-JavaScript (ex: Sass and Stylus) dependencies:\n\n```js\nconst fs = require('fs');\nconst content = fs.readFileSync('styles.scss', 'utf8');\n\nconst sassDeps = precinct(content, { type: 'sass' });\nconst stylusDeps = precinct(content, { type: 'stylus' });\n```\n\nOr, if you just want to pass in a filepath and get the dependencies:\n\n```js\nconst { paperwork } = require('precinct');\n\nconst deps = paperwork('myFile.js');\nconst deps2 = paperwork('styles.scss');\n```\n\n### `precinct.paperwork(filename, options)`\n\nSupported options:\n\n* `includeCore`: (default: `true`) set to `false` to exclude core Node.js dependencies from the list of dependencies.\n* `fileSystem`: (default: `undefined`) set to an alternative `fs` implementation that will be used to read the file path.\n* You may also pass detective-specific configuration like you would to `precinct(content, options)`.\n\n### CLI\n\nAssumes a global install precinct with `npm install -g precinct`.\n\n```sh\nprecinct [options] path/to/file\n```\n\nRun `precinct --help` to see all options.\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1738416524031,"maintainers":[{"name":"pahen","email":"patrik.henningsson@gmail.com"},{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_cnpm_publish_time":1738416524031,"dist-tags":{"latest":"13.0.1"}}