cli #

Run in any directory with TypeScript or Svelte source files. Prints JSON describing your project's exports to stdout.

Basic usage
#

npx svelte-docinfo # analyze the current directory npx svelte-docinfo ./packages/my-lib # analyze a specific directory npx svelte-docinfo -o output.json # write to a file instead npx svelte-docinfo --pretty # pretty-print the JSON output

Discovery defaults to package.json exports, falling back to glob. -i forces explicit patterns; --discovery glob skips exports; --discovery exports is strict (fails when exports is missing).

--source-dir sets the source directory (default src/lib, repeatable for monorepos) and seeds the implicit include glob. --source-root controls module-path stripping in the output (defaults to the single --source-dir or their longest common prefix).

Compact JSON pairs well with jq:

npx svelte-docinfo | jq '.modules | length' # count modules npx svelte-docinfo | jq -r '.modules[].declarations[].name' # list all exported names

JSON goes to stdout; info, warnings, and errors go to stderr, so the terminal interleaves them, but > and | capture clean JSON. -q/--quiet silences info; warnings and errors still print.

Options
#

FlagDescription
[project-root]project root directory (default: cwd)
-i, --include <pattern>include pattern (repeatable, replaces exports discovery)
-e, --exclude <pattern>exclude glob, applied at discovery and analysis (repeatable; fully replaces defaults, so it does not merge with **/*.test.ts, **/*.spec.ts)
-o, --output <file>output file (default: stdout; pass - for explicit stdout, so -o "$OUT" works when $OUT=-)
--discovery <mode>auto | exports | glob (default: auto: exports first, glob fallback). exports is strict and fails when package.json exports is missing.
--dist-dir <dir>dist directory for exports discovery (default: dist)
--source-dir <dir>source directory relative to project root (default: src/lib). Repeatable for monorepos; also seeds the implicit include glob.
--source-root <dir>source root for module-path stripping (default: single source-dir or longest common prefix)
--on-duplicates <mode>dispatch on duplicate declaration names: throw | warn (default: emit duplicate_declaration diagnostic, no dispatch)
--only <pattern>glob filter applied to module paths in output (repeatable). Full project is still analyzed (re-exports/dependents stay correct); diagnostics aren't filtered
--no-resolve-dependenciesdisable dependency resolution
--prettypretty-print JSON output (default: compact)
-q, --quietsuppress info messages on stderr (warnings and errors still print)
-V, --versionshow version number

Exit codes: 0 success, 1 analysis errors, 2 CLI errors.

For SvelteKit and Vite projects where the analysis feeds into your app bundle, see the Vite plugin.