validate-package-exports
v1.3.3
Published
Validate your package.json exports actually exist, have valid syntax, and can be imported or required without issues.
Maintainers
Readme
validate-package-exports
Validate your package.json exports actually exist, have valid syntax, and can be imported or required without issues.
Install
pnpm add validate-package-exports -Dnpm i validate-package-exports -Dyarn add validate-package-exports -DOptions
| Flag | Description | Default value |
| --- | --- | --- |
| --concurrency / -c | How many tasks to do at the same time | availableParallelism() |
| --dev-condition | Specify which custom conditions are used only during development | none |
| --bail / -b | Stop processing at the first error.Enabled by default when CI=true | process.env.CI === 'true' |
| --no-bail | Turn off --bail | false |
| --check / -s | Check syntax of JS files | false |
| --reporter | Reporter to use for output | text |
| --verbose | Use verbose output | false |
| --info / -i | Show info messages.Enabled by default when RUNNER_DEBUG=1 | process.env.RUNNER_DEBUG === '1' |
| --no-info | Turn off --info | false |
| --version / -v | Print the version number | false |
| --help / -h | Show the help screen | false |
Reporters
| Reporter | Description |
| --- | --- |
| text | Human-readable output with icons and colors. This is the default. |
| json | A single JSON array containing all results. |
| ndjson | Newline-delimited JSON. Each result is written as its own JSON object as soon as it's available. |
| sarif | SARIF 2.1.0 output, useful for integrating with tools like GitHub code scanning. |
Usage
validate-package-exports [FILE]... [options]:information_source: If you do not provide a path to a package.json, it will try to find one in the current directory.
Piping in
You can pipe in the list of packages to validate.
Validate all locally defined packages in your repo
pnpm ls -r --depth -1 --parseable | pnpm dlx validate-package-exports --infoPackage scripts examples
{
"scripts": {
"build": "YOUR-BUILD-SCRIPT",
"postbuild": "validate-package-exports --check"
}
}OR
{
"scripts": {
"prepublishOnly": "validate-package-exports --check"
}
}Dev Condition
If you use a customCondition in your tsconfig.json, like when using Nx, you can use the --dev-condition flag so that those entry points are skipped when validating which files are packed.
{
"scripts": {
"prepublishOnly": "validate-package-exports --check --info --dev-condition @example/monorepo"
}
}Using npx
npx --yes validate-package-exports ./path/to/package.json --checkLocal development
fnm use
corepack enable
pnpm install
pnpm buildUse local build
Run in separate tabs.
pnpm build -w./dist/cli.mjs [FILE]... [OPTIONS]Validate all packages in node_modules
This example demonstrates how you can bulk validate packages by piping in the package.json paths (one per line).
find -L ./node_modules -type d -name '.*' -prune -o \
-type f -regex '.*/node_modules/\(@[^/]+/\)?[^/]+/package\.json' -print | ./dist/cli.mjs