{"name":"precinct","version":"13.0.1","description":"Unleash the detectives","type":"module","exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"scripts":{"generate:types":"tsc --allowJs --declaration --emitDeclarationOnly --declarationDir . index.js","check:types":"npm run generate:types && git diff HEAD --exit-code index.d.ts","lint":"xo","fix":"xo --fix","vitest":"vitest","test":"npm run lint && npm run check:types && vitest run","test:ci":"vitest run --coverage"},"bin":{"precinct":"bin/cli.js"},"repository":{"type":"git","url":"git+https://github.com/dependents/node-precinct.git"},"keywords":["modules","amd","commonjs","es6","sass","less","vue","detective","dependencies"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","bugs":{"url":"https://github.com/dependents/node-precinct/issues"},"engines":{"node":">=20.19.0 || >=22.12.0"},"homepage":"https://github.com/dependents/node-precinct","dependencies":{"@dependents/detective-less":"^6.0.1","commander":"^14.0.3","detective-amd":"^7.0.0","detective-cjs":"^7.0.0","detective-es6":"^6.0.0","detective-postcss":"^9.0.1","detective-sass":"^7.0.1","detective-scss":"^6.0.1","detective-stylus":"^6.0.0","detective-typescript":"^15.0.1","detective-vue2":"^3.0.1","module-definition":"^7.0.0","node-source-walk":"^8.0.0","postcss":"^8.5.19","typescript":"^6.0.3"},"devDependencies":{"@babel/parser":"^7.29.7","@vitest/coverage-v8":"^4.1.10","vitest":"^4.1.10","xo":"^2.0.2"},"gitHead":"683469baaab178d2c17d1b05ad5e8de573b0260a","types":"./index.d.ts","_id":"precinct@13.0.1","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-mmrpDzb6tSF33WsEi7hds6xJlr85eU0nuhkiYR6PBwcgdvp5fPZ4FNx8c2IqlmZqrG5+wgwRTDfaZXbfWuyWmA==","shasum":"5cc28578d9ebd8b4b1329b0fa722dbff19f98030","tarball":"http://registry-npm.ywwl.com/precinct/download/precinct-13.0.1.tgz","fileCount":6,"unpackedSize":15980,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHj4W4CrhS7E5DKb7fhSvGf6R0qjZvTxGXD3FWcrfp8sAiEAg1Wd7ll3BLvJihW3qgHdUGbr7h/TZfiyHmZl7wVhQxc="}],"size":5632,"noattachment":false,"key":"/precinct/-/precinct-13.0.1.tgz"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"directories":{},"maintainers":[{"name":"pahen","email":"patrik.henningsson@gmail.com"},{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/precinct_13.0.1_1784135966036_0.22718534773614363"},"_hasShrinkwrap":false,"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":1784135966183,"_cnpm_publish_time":1784135966183,"dist-tags":{"latest":"13.0.1"}}