{"name":"precinct","version":"12.3.2","keywords":["modules","amd","commonjs","es6","sass","less","vue","detective","dependencies"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","_id":"precinct@12.3.2","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-precinct","bugs":{"url":"https://github.com/dependents/node-precinct/issues"},"bin":{"precinct":"bin/cli.js"},"dist":{"shasum":"0d6a15d2e9951744a24f5de6ab27c9b269365119","tarball":"http://registry-npm.ywwl.com/precinct/download/precinct-12.3.2.tgz","fileCount":6,"integrity":"sha512-JbJevI1K80z8e/WIyDt/4vUN/4qcfBSKKqOjJA4mosPPPb7zODKRJQV7YN7apVWN3k58nZYm/vEsLgEGYmnxwg==","signatures":[{"sig":"MEUCIGKjc5lqMjO15i4eybE4AVyPJaZe4wEj2RlP4yFvuc/xAiEAtl9cMHd2loHZ0tcM9ojSrgNAugSZq7o3oHxVDVsLS+w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13857,"size":4993,"noattachment":false,"key":"/precinct/-/precinct-12.3.2.tgz"},"main":"index.js","types":"index.d.ts","engines":{"node":">=18"},"gitHead":"9d9c1457f8a5fdea710a811f51f10640b5b43664","scripts":{"fix":"xo --fix","uvu":"uvu test \".test.js\" -i fixtures","lint":"xo","test":"npm run lint && npm run check:types && npm run uvu","test:ci":"c8 npm run uvu","check:types":"npm run generate:types && git diff HEAD --exit-code index.d.ts","generate:types":"tsc --allowJs --declaration --emitDeclarationOnly --declarationDir . index.js"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"repository":{"url":"git+https://github.com/dependents/node-precinct.git","type":"git"},"_npmVersion":"11.12.1","description":"Unleash the detectives","directories":{},"_nodeVersion":"24.15.0","dependencies":{"postcss":"^8.5.14","commander":"^12.1.0","typescript":"^5.9.3","detective-amd":"^6.1.0","detective-cjs":"^6.1.1","detective-es6":"^5.0.2","detective-sass":"^6.0.2","detective-scss":"^5.0.2","detective-vue2":"^2.3.0","detective-stylus":"^5.0.1","node-source-walk":"^7.0.2","detective-postcss":"^8.0.3","module-definition":"^6.0.2","detective-typescript":"^14.1.2","@dependents/detective-less":"^5.0.3"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^0.60.0","uvu":"^0.5.6"},"_npmOperationalInternal":{"tmp":"tmp/precinct_12.3.2_1778078303693_0.9479511165040737","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](https://img.shields.io/npm/dm/precinct)](https://www.npmjs.com/package/precinct)\n\n> Unleash the detectives\n\nUses the appropriate detective to find the dependencies of a file or its AST.\n\nSupports:\n\n- JavaScript modules: AMD, CommonJS, ES6\n- TypeScript\n- CSS preprocessors: Sass, Scss, Less, Stylus\n- CSS (PostCSS)\n- Vue\n\n## Install\n\n```sh\nnpm install precinct\n```\n\n## Quick start\n\n```js\n// ESM\nimport fs from 'node:fs';\nimport precinct from 'precinct';\n// CommonJS\nconst fs = require('node:fs');\nconst { default: precinct } = require('precinct');\n\nconst content = fs.readFileSync('myFile.js', 'utf8');\n\n// From source content or an AST\nconst deps = precinct(content);\n\n// Or directly from a file path\nconst deps2 = precinct.paperwork('styles.scss');\n```\n\n## API\n\n### `precinct(content, options?)`\n\nReturns an array of dependency strings discovered in `content`. `content` may be a source string or an already-parsed AST.\n\n| Option | Type | Default | Notes |\n|---|---|---|---|\n| `type` | `string` | inferred from source | Forces a specific detective. See [Supported types](#supported-types). |\n| `walker` | `object` | - | Passed through to the underlying [node-source-walk](https://github.com/dependents/node-source-walk) instance - e.g. `{ allowImportExportEverywhere: true }`, or `{ parser: myCustomParser }` to swap in a parser with a `.parse(src, opts)` method. |\n| `amd.skipLazyLoaded` | `boolean` | `false` | Omit lazy-loaded (inner-`require`) dependencies in AMD files. |\n| `es6.mixedImports` | `boolean` | `false` | Return both ES6 and CommonJS imports from a file that mixes the two. Works for any format that contains an ES6 import. |\n| `css.url` | `boolean` | `false` | Include `url()` references (images, fonts, etc.) in CSS output. |\n| `[type]` | `object` | - | Any other key matching a module type is forwarded to that detective as its options bag. |\n\nSide channel: `precinct.ast` holds the last AST produced (or `null` when parsing failed).\n\n#### Example\n\n```js\nprecinct(content, {\n  type: 'amd',\n  amd: {\n    skipLazyLoaded: true\n  }\n});\n\nprecinct(content, {\n  walker: {\n    allowImportExportEverywhere: true\n  }\n});\n\n// Non-JS content\nprecinct(scssSource, { type: 'scss' });\nprecinct(stylusSource, { type: 'stylus' });\n```\n\n### `precinct.paperwork(filename, options?)`\n\nReads the file at `filename` and returns an array of its dependencies. The module type is inferred from the file extension (see below). Accepts every option `precinct()` does, plus the two below.\n\n| Option | Type | Default | Notes |\n|---|---|---|---|\n| `includeCore` | `boolean` | `true` | Set to `false` to strip Node.js core modules (`fs`, `path`, `node:fs`, ...) from the result. |\n| `fileSystem` | `{ readFileSync(path, encoding): string }` | `node:fs` | An alternative `fs` implementation used to read `filename`. Only `readFileSync(path, 'utf8')` is required. |\n| `walker`, `amd`, `es6`, `css`, `[type]` | - | - | Same as `precinct()` - all detective options are forwarded. |\n\n#### Example\n\n```js\n// ESM\nimport { paperwork } from 'precinct';\n// CommonJS\nconst { paperwork } = require('precinct');\n\nconst deps = paperwork('myFile.js');\nconst deps2 = paperwork('styles.scss');\nconst deps3 = paperwork('app.ts', { includeCore: false });\n```\n\n## Supported types\n\nAccepted values for the `type` option:\n\n| Value | Detective |\n|---|---|\n| `amd` | [detective-amd](https://github.com/dependents/node-detective-amd) |\n| `cjs`, `commonjs` | [detective-cjs](https://github.com/dependents/node-detective-cjs) |\n| `css` | [detective-postcss](https://github.com/dependents/node-detective-postcss) |\n| `es6`, `esm`, `mjs` | [detective-es6](https://github.com/dependents/node-detective-es6) |\n| `less` | [@dependents/detective-less](https://github.com/dependents/node-detective-less) |\n| `sass` | [detective-sass](https://github.com/dependents/node-detective-sass) |\n| `scss` | [detective-scss](https://github.com/dependents/node-detective-scss) |\n| `stylus` | [detective-stylus](https://github.com/dependents/node-detective-stylus) |\n| `ts` | [detective-typescript](https://github.com/dependents/detective-typescript) |\n| `tsx` | [detective-typescript](https://github.com/dependents/detective-typescript) (tsx variant) |\n| `vue` | [detective-vue2](https://github.com/dependents/detective-vue2) |\n\n`paperwork()` infers the type from the filename extension; `.styl` maps to `stylus` and `.cjs` maps to `commonjs`. Any other extension becomes the type with the leading dot stripped. `.js` and `.jsx` are sniffed at the source level rather than by extension.\n\n## CLI\n\n```sh\nnpm install -g precinct\nprecinct [options] <filename>\n```\n\n| Flag | Description |\n|---|---|\n| `-t, --type <type>` | Force a module type (see [Supported types](#supported-types)). |\n| `--es6-mixed-imports` | Collect both ES6 and CommonJS imports in the same file. |\n| `-V, --version` | Print version. |\n| `-h, --help` | Print help. |\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1778078303883,"_cnpm_publish_time":1778078303883,"dist-tags":{"latest":"13.0.1"}}