svelte-docinfo 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -226,12 +226,12 @@ Plugin options:
226
226
  | `projectRoot` | Vite's resolved `config.root` | Absolute path to project root. |
227
227
  | `include` | — | Glob patterns to include (relative to `projectRoot`; absolute inside it accepted). Collapses `discovery: 'auto'` to glob; combining with `discovery: 'exports'` throws. Widens the source scope — see the notes below. |
228
228
  | `exclude` | `['**/*.test.ts', '**/*.spec.ts', '**/internal/**']` | Glob patterns to exclude. An array fully replaces the defaults; the callback form extends them (`(defaults) => [...defaults, '**/*.gen.ts']`). The always-on baseline below still applies. |
229
- | `discovery` | `'auto'` | Discovery strategy: `'auto'` \| `'exports'` \| `'glob'`. `'exports'` is strict and fails if `package.json` exports is missing or resolves to no files. |
229
+ | `discovery` | `'auto'` | Discovery strategy: `'auto'` \| `'exports'` \| `'glob'`. `'exports'` is strict and fails if `package.json` exports is missing or resolves to no files. |
230
230
  | `distDir` | `'dist'` | Dist directory name for exports-based discovery. |
231
231
  | `sourceOptions` | `{sourcePaths: ['src/lib'], …}` | Partial overrides for default source options (SvelteKit `src/lib` layout). |
232
232
  | `resolveDependencies` | `true` | Resolve import dependencies. When `false`, `dependencies`/`dependents` stay empty. |
233
- | `onDuplicates` | — | Dispatch on duplicate declaration names: `'throw'` \| `'warn'` \| callback. Diagnostic emits regardless of dispatch. |
234
233
  | `hmrDebounceMs` | `100` | Dev re-analysis debounce delay in milliseconds. |
234
+ | `onDuplicates` | — | Opt-in check that names are unique across modules, for packages with a flat export namespace: `'diagnostic'` \| `'warn'` \| `'throw'`. Off by default. |
235
235
 
236
236
  Source-scope notes (shared with the [CLI](#cli) and `analyzeFromFiles`):
237
237
 
@@ -274,21 +274,21 @@ All CLI options:
274
274
  | `-i, --include <pattern>` | Include pattern (repeatable, replaces exports discovery, widens the source scope; incompatible with `--discovery exports`) |
275
275
  | `-e, --exclude <pattern>` | Exclude glob, applied at discovery and analysis (repeatable; fully replaces the defaults `**/*.test.ts`, `**/*.spec.ts`, `**/internal/**` — no merge; the always-on baseline applies beneath) |
276
276
  | `-o, --output <file>` | Output file (default: stdout; pass `-` for explicit stdout, so `-o "$OUT"` works when `$OUT=-`) |
277
- | `--discovery <mode>` | `auto` \| `exports` \| `glob` (default: `auto` — exports first, glob fallback). `exports` is strict and fails if package.json exports is missing or resolves to no files |
277
+ | `--discovery <mode>` | `auto` \| `exports` \| `glob` (default: `auto` — exports first, glob fallback). `exports` is strict and fails if package.json exports is missing or resolves to no files |
278
278
  | `--dist-dir <dir>` | Dist directory for exports discovery (default: dist) |
279
279
  | `--source-dir <dir>` | Source directory, relative to project root or absolute inside it (default: src/lib). Repeatable for monorepos; drives the implicit include glob when no `--include` is provided |
280
280
  | `--source-root <dir>` | Source root for module-path stripping (default: single source-dir or longest common prefix; pass `.` for project-relative paths) |
281
- | `--on-duplicates <mode>` | Dispatch on duplicate declaration names: `throw` \| `warn` (default: emit `duplicate_declaration` diagnostic, no dispatch) |
282
281
  | `--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 |
283
282
  | `--no-resolve-dependencies` | Disable dependency resolution |
284
283
  | `--pretty` | Pretty-print JSON output (default: compact) |
285
284
  | `-q, --quiet` | Suppress info messages on stderr (warnings and errors still print) |
285
+ | `--on-duplicates <mode>` | Opt-in check that names are unique across modules, for packages with a flat export namespace: `diagnostic` \| `warn` \| `throw` (default: off) |
286
286
  | `-V, --version` | Show version number |
287
287
 
288
288
  The [Vite plugin](#vite-plugin)'s source-scope notes apply here too: explicit `--include` patterns widen the source scope (module paths become relative to the widened root, and a pattern with no base scopes the whole project root and logs an info line); `node_modules` and dot-directories below a source dir are always excluded regardless of `--exclude`; absolute paths and patterns inside the project root are accepted, and out-of-root ones fail loudly.
289
289
 
290
290
  Exit codes: 0 (success), 1 (analysis errors), 2 (CLI errors or a thrown analysis error, like a
291
- missing or unloadable `tsconfig.json` or an `--on-duplicates throw` collision).
291
+ missing or unloadable `tsconfig.json`).
292
292
 
293
293
  See [examples/cli/](examples/cli/README.md) for more usage patterns.
294
294
 
@@ -13,10 +13,8 @@
13
13
  * - `analyzeModule` — the per-module dispatcher for non-Svelte files (TS / CSS /
14
14
  * JSON; Svelte needs `analyzeSvelteModule`). `@internal`; exposed for tests
15
15
  * and power users via the subpath.
16
- * - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` /
17
- * `OnDuplicatesCallback` — shared types surfaced through the main barrel
18
- * directly from this module.
19
- * - `throwOnDuplicates` — convenience callback paired with `OnDuplicates`.
16
+ * - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` — shared
17
+ * types surfaced through the main barrel directly from this module.
20
18
  * - `finalizeDiagnostics` — the diagnostic boundary passes (virtual position
21
19
  * remap, then path normalization) in their required order; the one call for
22
20
  * callers assembling modules themselves.
@@ -28,7 +26,7 @@
28
26
  * assembling modules itself through `analyzeModule` can meet the same
29
27
  * output contract.
30
28
  *
31
- * The barrel-surfaced schemas, types, and `throwOnDuplicates` are stable API.
29
+ * The barrel-surfaced schemas and types are stable API.
32
30
  * Everything else is subpath-only; `analyzeCore` and `analyzeModule` are
33
31
  * `@internal`.
34
32
  *
@@ -43,47 +41,25 @@ import { type SvelteVirtualFile } from './svelte.js';
43
41
  import { type SourceFileInfo } from './source.js';
44
42
  import { type ModuleSourceOptions } from './source-config.js';
45
43
  import type { AliasRegistry } from './typescript-extract-type-json.js';
46
- import { type DuplicateDeclaration } from './postprocess.js';
47
44
  /**
48
- * Custom callback for handling duplicate declaration names.
45
+ * Opt-in check that declaration names are unique across modules.
49
46
  *
50
- * Use the `'throw'` or `'warn'` shortcuts on `onDuplicates` for the common
51
- * cases. Pass a function to fully control reporting.
47
+ * For packages that keep a flat export namespace, where every exported name
48
+ * is unique across the whole package. Most packages don't, and two modules
49
+ * exporting the same name is ordinary, so the check is off by default:
50
+ * omitted, duplicate detection doesn't run and nothing is reported.
52
51
  *
53
- * @param duplicates - map of declaration names to their `DuplicateDeclaration` occurrences across modules
54
- * @param log - logger for reporting (only `error` method required)
55
- */
56
- export type OnDuplicatesCallback = (duplicates: Map<string, Array<DuplicateDeclaration>>, log: Pick<AnalysisLog, 'error'>) => void;
57
- /**
58
- * Behavior selector for duplicate declaration names across modules.
59
- *
60
- * - `'throw'` — throw an `Error` listing every duplicate (strict flat-namespace enforcement)
61
- * - `'warn'` — log to `log.error` and continue
62
- * - `OnDuplicatesCallback` — custom handler
63
- *
64
- * Omitted entirely: no dispatch runs, but a `duplicate_declaration` diagnostic
65
- * is still emitted into the diagnostics array for every collision (the diagnostic
66
- * is the data; this option is the action).
52
+ * Every mode emits a `duplicate_declaration` diagnostic per colliding name:
67
53
  *
68
- * **`'throw'` trade-off**: the throw fires after diagnostics are emitted but
69
- * before the result is returned, so `'throw'` callers never reach the
70
- * diagnostics array. Callers that want fail-fast *and* diagnostic access
71
- * should omit `onDuplicates` and inspect themselves:
72
- *
73
- * ```ts
74
- * const result = await analyze({...});
75
- * if (hasErrors(result.diagnostics)) throw new Error('analysis errors');
76
- * ```
77
- *
78
- * Or use an `OnDuplicatesCallback` and stash the data before throwing.
79
- */
80
- export type OnDuplicates = 'throw' | 'warn' | OnDuplicatesCallback;
81
- /**
82
- * Convenience `OnDuplicatesCallback` that throws on any duplicate.
54
+ * - `'diagnostic'` — the diagnostics only
55
+ * - `'warn'` — also log the collisions to `log.warn` and continue
56
+ * - `'throw'` — also throw an `Error` listing every duplicate
83
57
  *
84
- * @throws Error listing every duplicate name and module location
58
+ * The throw fires before the result is returned, so `'throw'` callers never
59
+ * reach the diagnostics array. For custom handling, use `'diagnostic'` and
60
+ * read the records with `byKind(diagnostics, 'duplicate_declaration')`.
85
61
  */
86
- export declare const throwOnDuplicates: OnDuplicatesCallback;
62
+ export type OnDuplicates = 'diagnostic' | 'warn' | 'throw';
87
63
  /**
88
64
  * Result of `analyze`, `analyzeFromFiles`, and `AnalysisSession.query`.
89
65
  *
@@ -1 +1 @@
1
- {"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGN,KAAK,cAAc,EAEnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,mBAAmB,EAAoC,MAAM,oBAAoB,CAAC;AAGhG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,EAMN,KAAK,oBAAoB,EACzB,MAAM,kBAAkB,CAAC;AAI1B;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAClC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC,EACpD,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,oBAAoB,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,oBAG/B,CAAC;AA2EF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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`analyzeSvelteModule`). `@internal`; exposed for tests
15
15
  * and power users via the subpath.
16
- * - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` /
17
- * `OnDuplicatesCallback` — shared types surfaced through the main barrel
18
- * directly from this module.
19
- * - `throwOnDuplicates` — convenience callback paired with `OnDuplicates`.
16
+ * - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` — shared
17
+ * types surfaced through the main barrel directly from this module.
20
18
  * - `finalizeDiagnostics` — the diagnostic boundary passes (virtual position
21
19
  * remap, then path normalization) in their required order; the one call for
22
20
  * callers assembling modules themselves.
@@ -28,7 +26,7 @@
28
26
  * assembling modules itself through `analyzeModule` can meet the same
29
27
  * output contract.
30
28
  *
31
- * The barrel-surfaced schemas, types, and `throwOnDuplicates` are stable API.
29
+ * The barrel-surfaced schemas and types are stable API.
32
30
  * Everything else is subpath-only; `analyzeCore` and `analyzeModule` are
33
31
  * `@internal`.
34
32
  *
@@ -47,16 +45,6 @@ import { toPosixPath, isAbsolutePosixPath } from './paths.js';
47
45
  import { buildAliasRegistry } from './typescript-alias-registry.js';
48
46
  import { createExtractContext } from './typescript-extract-shared.js';
49
47
  import { sortModules, findDuplicates, mergeReExports, resolveComponentAliases, compareStrings } from './postprocess.js';
50
- /**
51
- * Convenience `OnDuplicatesCallback` that throws on any duplicate.
52
- *
53
- * @throws Error listing every duplicate name and module location
54
- */
55
- export const throwOnDuplicates = (duplicates) => {
56
- if (duplicates.size === 0)
57
- return;
58
- throw new Error(formatDuplicates(duplicates));
59
- };
60
48
  const formatDuplicates = (duplicates) => {
61
49
  const details = Array.from(duplicates)
62
50
  .map(([name, occurrences]) => {
@@ -70,9 +58,8 @@ const formatDuplicates = (duplicates) => {
70
58
  })
71
59
  .join('\n');
72
60
  return (`Found ${duplicates.size} duplicate declaration name${duplicates.size === 1 ? '' : 's'} across modules. ` +
73
- 'The flat namespace requires unique names. To resolve: ' +
74
- '(1) rename one of the conflicting declarations, or ' +
75
- '(2) add /** @nodocs */ to exclude from documentation.\n' +
61
+ 'To resolve, rename one of the conflicting declarations, ' +
62
+ 'or mark one /** @nodocs */ if it is not public API.\n' +
76
63
  details);
77
64
  };
78
65
  /**
@@ -103,17 +90,12 @@ const emitDuplicateDiagnostics = (diagnostics, duplicates, sourceIdsByModulePath
103
90
  }
104
91
  };
105
92
  const dispatchOnDuplicates = (mode, duplicates, log) => {
106
- if (duplicates.size === 0)
107
- return;
108
- if (mode === 'throw') {
109
- throw new Error(formatDuplicates(duplicates));
110
- }
111
- const errorLog = log ?? { error: (msg) => console.error(msg) };
112
- if (mode === 'warn') {
113
- errorLog.error(formatDuplicates(duplicates));
93
+ if (duplicates.size === 0 || mode === 'diagnostic')
114
94
  return;
115
- }
116
- mode(duplicates, errorLog);
95
+ const message = formatDuplicates(duplicates);
96
+ if (mode === 'throw')
97
+ throw new Error(message);
98
+ (log?.warn ?? console.warn)(message);
117
99
  };
118
100
  // Result types
119
101
  /**
@@ -418,13 +400,10 @@ export const analyzeCore = (inputs) => {
418
400
  // Gated canonicals extend the lookup without joining the output.
419
401
  const resolvedModules = resolveComponentAliases(mergedModules, contextModules);
420
402
  const sortedModules = sortModules(resolvedModules);
421
- // Always run duplicate detection so a `duplicate_declaration` diagnostic
422
- // reaches consumers regardless of `onDuplicates`. The `onDuplicates`
423
- // callback/shortcut still fires for callers that want fail-fast or custom
424
- // handling — diagnostics is the data, `onDuplicates` is the action.
425
- const duplicates = findDuplicates(sortedModules);
426
- emitDuplicateDiagnostics(diagnostics, duplicates, sourceIdsByModulePath);
403
+ // opt-in flat-namespace check, see `OnDuplicates`
427
404
  if (onDuplicates) {
405
+ const duplicates = findDuplicates(sortedModules);
406
+ emitDuplicateDiagnostics(diagnostics, duplicates, sourceIdsByModulePath);
428
407
  dispatchOnDuplicates(onDuplicates, duplicates, log);
429
408
  }
430
409
  normalizeModulePathsInTypes(sortedModules, sourceOptions, program);
package/dist/analyze.d.ts CHANGED
@@ -40,7 +40,7 @@ export interface AnalyzeOptions {
40
40
  sourceFiles: ReadonlyArray<SourceFileInfo>;
41
41
  /** Module source options for path extraction and source filtering. */
42
42
  sourceOptions: ModuleSourceOptions;
43
- /** Behavior when duplicate declaration names are found across modules. */
43
+ /** Opt-in check that declaration names are unique across modules (see `OnDuplicates`). */
44
44
  onDuplicates?: OnDuplicates;
45
45
  /** Optional logger for status and diagnostic messages. */
46
46
  log?: AnalysisLog;
@@ -78,7 +78,7 @@ export interface AnalyzeFromFilesOptions {
78
78
  projectRoot: string;
79
79
  /** Partial overrides for default source options (SvelteKit `src/lib` layout). */
80
80
  sourceOptions?: SourceOptionsOverrides;
81
- /** Behavior when duplicate declaration names are found across modules. */
81
+ /** Opt-in check that declaration names are unique across modules (see `OnDuplicates`). */
82
82
  onDuplicates?: OnDuplicates;
83
83
  /** Optional logger for status and diagnostic messages. */
84
84
  log?: AnalysisLog;
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;OAMG;IACH,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC3C,sEAAsE;IACtE,aAAa,EAAE,mBAAmB,CAAC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AAC;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,uBAAuB,KAC9B,OAAO,CAAC,iBAAiB,CAwH3B,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -17,10 +17,8 @@
17
17
  *
18
18
  * @module
19
19
  */
20
+ import type { OnDuplicates } from './analyze-core.js';
20
21
  import type { Discovery } from './discovery.js';
21
- /** Allowed values for `--on-duplicates`. */
22
- declare const ON_DUPLICATES_VALUES: readonly ["throw", "warn"];
23
- type OnDuplicatesFlag = (typeof ON_DUPLICATES_VALUES)[number];
24
22
  /**
25
23
  * CLI options parsed from command line arguments.
26
24
  */
@@ -76,13 +74,10 @@ export interface CliOptions {
76
74
  */
77
75
  sourceRoot?: string;
78
76
  /**
79
- * Behavior when duplicate declaration names are found across modules
80
- * (undefined = emit `duplicate_declaration` diagnostic, no dispatch).
81
- *
82
- * Duplicate detection always runs regardless of this option — the diagnostic
83
- * is the data, this option is the dispatch action.
77
+ * Opt-in check that declaration names are unique across modules (see
78
+ * `OnDuplicates`). Undefined skips the check.
84
79
  */
85
- onDuplicates?: OnDuplicatesFlag;
80
+ onDuplicates?: OnDuplicates;
86
81
  /**
87
82
  * Glob patterns to filter the emitted `modules` array against `ModuleJson.path`
88
83
  * (undefined = emit all analyzed modules).
@@ -105,5 +100,4 @@ export interface CliOptions {
105
100
  * thrown analysis error (including an `--on-duplicates throw` collision)
106
101
  */
107
102
  export declare const runCli: (argv?: Array<string>) => Promise<number>;
108
- export {};
109
103
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAUH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;A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wBhD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAU,OAAM,KAAK,CAAC,MAAM,CAAgB,KAAG,OAAO,CAAC,MAAM,CA4N/E,CAAC"}
package/dist/cli.js CHANGED
@@ -29,7 +29,11 @@ import { compactReplacer } from './declaration-helpers.js';
29
29
  /** Collect repeatable option values into an array. */
30
30
  const collect = (value, previous) => previous ? [...previous, value] : [value];
31
31
  /** Allowed values for `--on-duplicates`. */
32
- const ON_DUPLICATES_VALUES = ['throw', 'warn'];
32
+ const ON_DUPLICATES_VALUES = [
33
+ 'diagnostic',
34
+ 'warn',
35
+ 'throw'
36
+ ];
33
37
  const isOnDuplicatesFlag = (value) => ON_DUPLICATES_VALUES.includes(value);
34
38
  /** Allowed values for `--discovery`. */
35
39
  const DISCOVERY_VALUES = ['auto', 'exports', 'glob'];
@@ -87,14 +91,16 @@ export const runCli = async (argv = process.argv) => {
87
91
  'glob for the glob-discovery fallback when no --include is provided.', collect)
88
92
  .option('--source-root <dir>', 'Prefix stripped from module paths in output (default: the source-dir, ' +
89
93
  'or longest common prefix when multiple). Pass `.` to keep paths project-relative.')
90
- .option('--on-duplicates <mode>', `Dispatch on duplicate declaration names across modules: ${ON_DUPLICATES_VALUES.join('|')} ` +
91
- '(default: emit duplicate_declaration diagnostic, no dispatch)')
92
94
  .option('--only <pattern>', 'Glob filter applied to module paths in output (repeatable). ' +
93
95
  'Full project is still analyzed — re-exports/dependents stay correct — ' +
94
96
  'but only matching modules are emitted. Diagnostics are not filtered ' +
95
97
  'and may reference modules dropped from output.', collect)
96
98
  .option('--pretty', 'Pretty-print JSON output', false)
97
99
  .option('-q, --quiet', 'Suppress info messages on stderr (warnings and errors still print)', false)
100
+ .option('--on-duplicates <mode>', 'Opt-in check that declaration names are unique across modules, ' +
101
+ `for packages with a flat export namespace: ${ON_DUPLICATES_VALUES.join('|')} ` +
102
+ '(default: off). Every mode emits duplicate_declaration diagnostics; ' +
103
+ 'warn also logs them and throw fails the run.')
98
104
  .addHelpText('after', `
99
105
  Examples:
100
106
  $ svelte-docinfo Analyze current project
@@ -107,7 +113,6 @@ Examples:
107
113
  No common prefix — module paths stay project-relative
108
114
  $ svelte-docinfo --discovery glob Skip package.json exports
109
115
  $ svelte-docinfo --discovery exports Strict — fail if exports missing
110
- $ svelte-docinfo --on-duplicates throw Enforce flat namespace
111
116
  $ svelte-docinfo --only 'components/**' Emit only modules under components/
112
117
  $ svelte-docinfo --only '*.svelte' Emit only Svelte modules (top-level)
113
118
  $ svelte-docinfo | jq . Pipe to jq for readable output`)
@@ -156,7 +161,6 @@ Examples:
156
161
  ...(options.sourceRoot !== undefined ? { sourceRoot: options.sourceRoot } : {})
157
162
  }
158
163
  : undefined;
159
- const onDuplicates = options.onDuplicates;
160
164
  const { modules, diagnostics } = await analyzeFromFiles({
161
165
  projectRoot: resolvedRoot,
162
166
  include: options.include,
@@ -165,7 +169,7 @@ Examples:
165
169
  discovery: options.discovery,
166
170
  distDir: options.distDir,
167
171
  ...(sourceOptions !== undefined ? { sourceOptions } : {}),
168
- ...(onDuplicates !== undefined ? { onDuplicates } : {}),
172
+ ...(options.onDuplicates !== undefined ? { onDuplicates: options.onDuplicates } : {}),
169
173
  log
170
174
  });
171
175
  // `--only` is an output-only filter: analysis ran against the full
@@ -677,11 +677,11 @@ export type UnknownParamDiagnostic = z.infer<typeof UnknownParamDiagnostic>;
677
677
  /**
678
678
  * A declaration `name` appears in more than one module.
679
679
  *
680
- * Library docs assume a flat namespace — two modules exporting the same name
681
- * collide when consumers `import {name}`. Emitted at `warning` severity so
682
- * the analysis result remains usable; consumers who want it fatal can promote
683
- * via `onDuplicates: 'throw'` or by inspecting the diagnostic. The default
684
- * slot (`name === 'default'`) is excluded — every module owns its own.
680
+ * Opt-in: emitted only when `onDuplicates` is set, for packages that keep a
681
+ * flat export namespace (see `OnDuplicates`). Emitted at `warning` severity
682
+ * so the analysis result remains usable; `onDuplicates: 'throw'` makes it
683
+ * fatal. The default slot (`name === 'default'`) is excluded — every module
684
+ * owns its own.
685
685
  */
686
686
  export declare const DuplicateDeclarationDiagnostic: z.ZodObject<{
687
687
  /** The duplicated declaration name. */
@@ -315,11 +315,11 @@ export const UnknownParamDiagnostic = z.strictObject({
315
315
  /**
316
316
  * A declaration `name` appears in more than one module.
317
317
  *
318
- * Library docs assume a flat namespace — two modules exporting the same name
319
- * collide when consumers `import {name}`. Emitted at `warning` severity so
320
- * the analysis result remains usable; consumers who want it fatal can promote
321
- * via `onDuplicates: 'throw'` or by inspecting the diagnostic. The default
322
- * slot (`name === 'default'`) is excluded — every module owns its own.
318
+ * Opt-in: emitted only when `onDuplicates` is set, for packages that keep a
319
+ * flat export namespace (see `OnDuplicates`). Emitted at `warning` severity
320
+ * so the analysis result remains usable; `onDuplicates: 'throw'` makes it
321
+ * fatal. The default slot (`name === 'default'`) is excluded — every module
322
+ * owns its own.
323
323
  */
324
324
  export const DuplicateDeclarationDiagnostic = z.strictObject({
325
325
  kind: z.literal('duplicate_declaration'),
package/dist/index.d.ts CHANGED
@@ -10,8 +10,8 @@
10
10
  */
11
11
  export { analyze, analyzeFromFiles } from './analyze.js';
12
12
  export type { AnalyzeOptions, AnalyzeFromFilesOptions } from './analyze.js';
13
- export { throwOnDuplicates, AnalyzeResultJson } from './analyze-core.js';
14
- export type { AnalyzeResultJsonWire, OnDuplicates, OnDuplicatesCallback } from './analyze-core.js';
13
+ export { AnalyzeResultJson } from './analyze-core.js';
14
+ export type { AnalyzeResultJsonWire, OnDuplicates } from './analyze-core.js';
15
15
  export { createAnalysisSession } from './session.js';
16
16
  export type { AnalysisSession, AnalysisSessionOptions, SetFileOptions, SetFileResult, SetFilesResult, QueryOptions } from './session.js';
17
17
  export { normalizeResolveImport } from './dep-resolver.js';
@@ -23,8 +23,8 @@ export { getDefaultAnalyzer } from './source.js';
23
23
  export type { SourceFileInfo, AnalyzerType } from './source.js';
24
24
  export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
25
25
  export type { ExcludeOption, ModuleSourceOptions, SourceOptionsDefaults, SourceOptionsOverrides } from './source-config.js';
26
- export { findDuplicates, mergeReExports, resolveComponentAliases, resolveExportSurface } from './postprocess.js';
27
- export type { DuplicateDeclaration, ExportSurface, ExportSurfaceEntry } from './postprocess.js';
26
+ export { mergeReExports, resolveComponentAliases, resolveExportSurface } from './postprocess.js';
27
+ export type { ExportSurface, ExportSurfaceEntry } from './postprocess.js';
28
28
  export { deriveIncludePatterns } from './files.js';
29
29
  export { discoverSourceFiles } from './discovery.js';
30
30
  export type { Discovery, DiscoverSourceFilesOptions, DiscoverSourceFilesResult } from './discovery.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GAS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AAgB,CAAC;AAIxB,OAAO,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACR,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  */
11
11
  // Core entry points
12
12
  export { analyze, analyzeFromFiles } from './analyze.js';
13
- export { throwOnDuplicates, AnalyzeResultJson } from './analyze-core.js';
13
+ export { AnalyzeResultJson } from './analyze-core.js';
14
14
  export { createAnalysisSession } from './session.js';
15
15
  export { normalizeResolveImport } from './dep-resolver.js';
16
16
  // Types (Zod schemas + TypeScript interfaces)
@@ -22,7 +22,7 @@ export { getDefaultAnalyzer } from './source.js';
22
22
  // Source options
23
23
  export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
24
24
  // Post-processing
25
- export { findDuplicates, mergeReExports, resolveComponentAliases, resolveExportSurface } from './postprocess.js';
25
+ export { mergeReExports, resolveComponentAliases, resolveExportSurface } from './postprocess.js';
26
26
  // File system helpers
27
27
  export { deriveIncludePatterns } from './files.js';
28
28
  // File discovery
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * These functions transform analysis results after module-level analysis is complete:
5
5
  *
6
- * 1. **Validation** — `findDuplicates` checks flat namespace constraints
6
+ * 1. **Validation** — `findDuplicates` checks the opt-in flat-namespace constraint
7
7
  * 2. **Transformation** — `mergeReExports` resolves re-export relationships,
8
8
  * `resolveComponentAliases` fills component aliases from their canonicals,
9
9
  * `computeDependents` builds bidirectional dependency graphs
@@ -42,22 +42,14 @@ export interface DuplicateDeclaration {
42
42
  * (`export {default as Foo} from './Foo.svelte'`) therefore doesn't flag.
43
43
  * When a name does flag, all occurrences are reported, aliases included.
44
44
  *
45
- * Callers can decide how to handle duplicates (throw, warn, ignore).
45
+ * The analysis entry points run this only under the opt-in `onDuplicates`.
46
46
  *
47
47
  * @returns `Map` of declaration names to their `DuplicateDeclaration` occurrences (only includes duplicates)
48
48
  *
49
49
  * @example
50
50
  * ```ts
51
51
  * const duplicates = findDuplicates(modules);
52
- * if (duplicates.size > 0) {
53
- * for (const [name, occurrences] of duplicates) {
54
- * console.error(`"${name}" found in:`);
55
- * for (const {declaration, module} of occurrences) {
56
- * console.error(` - ${module}:${declaration.sourceLine} (${declaration.kind})`);
57
- * }
58
- * }
59
- * throw new Error(`Found ${duplicates.size} duplicate declaration names`);
60
- * }
52
+ * duplicates.get('parse'); // [{declaration, module: 'a.ts'}, {declaration, module: 'b.ts'}]
61
53
  * ```
62
54
  */
63
55
  export declare const findDuplicates: (modules: Array<ModuleJson>) => Map<string, Array<DuplicateDeclaration>>;
@@ -1 +1 @@
1
- {"version":3,"file":"postprocess.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/postprocess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAA4B,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA0ClD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,qCAAqC;IACrC,WAAW,EAAE,eAAe,CAAC;IAC7B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;CACf;AA6CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc,GAC1B,SAAS,KAAK,CAAC,UAAU,CAAC,KACxB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAwCzC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAMrD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,KAAK,CAAC,UAAU,CAAC,KAAG,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form analysis results after module-level analysis is complete:
5
5
  *
6
- * 1. **Validation** — `findDuplicates` checks flat namespace constraints
6
+ * 1. **Validation** — `findDuplicates` checks the opt-in flat-namespace constraint
7
7
  * 2. **Transformation** — `mergeReExports` resolves re-export relationships,
8
8
  * `resolveComponentAliases` fills component aliases from their canonicals,
9
9
  * `computeDependents` builds bidirectional dependency graphs
@@ -106,22 +106,14 @@ const resolveCanonicalIdentity = (byIdentity, modulePath, declaration) => {
106
106
  * (`export {default as Foo} from './Foo.svelte'`) therefore doesn't flag.
107
107
  * When a name does flag, all occurrences are reported, aliases included.
108
108
  *
109
- * Callers can decide how to handle duplicates (throw, warn, ignore).
109
+ * The analysis entry points run this only under the opt-in `onDuplicates`.
110
110
  *
111
111
  * @returns `Map` of declaration names to their `DuplicateDeclaration` occurrences (only includes duplicates)
112
112
  *
113
113
  * @example
114
114
  * ```ts
115
115
  * const duplicates = findDuplicates(modules);
116
- * if (duplicates.size > 0) {
117
- * for (const [name, occurrences] of duplicates) {
118
- * console.error(`"${name}" found in:`);
119
- * for (const {declaration, module} of occurrences) {
120
- * console.error(` - ${module}:${declaration.sourceLine} (${declaration.kind})`);
121
- * }
122
- * }
123
- * throw new Error(`Found ${duplicates.size} duplicate declaration names`);
124
- * }
116
+ * duplicates.get('parse'); // [{declaration, module: 'a.ts'}, {declaration, module: 'b.ts'}]
125
117
  * ```
126
118
  */
127
119
  export const findDuplicates = (modules) => {
package/dist/session.d.ts CHANGED
@@ -114,7 +114,7 @@ export interface SetFilesResult {
114
114
  * Per-call input to `query`.
115
115
  */
116
116
  export interface QueryOptions {
117
- /** Behavior when duplicate declaration names are found across modules. */
117
+ /** Opt-in check that declaration names are unique across modules (see `OnDuplicates`). */
118
118
  onDuplicates?: OnDuplicates;
119
119
  /** Per-call logger override (defaults to the session-level logger). */
120
120
  log?: AnalysisLog;
@@ -352,7 +352,7 @@ export interface AnalysisSessionOptions extends Omit<AnalysisLanguageServiceOpti
352
352
  * const session = createAnalysisSession({sourceOptions, contextClosure: false});
353
353
  * try {
354
354
  * await session.setFiles(sourceFiles);
355
- * return session.query({onDuplicates: 'throw'});
355
+ * return session.query();
356
356
  * } finally {
357
357
  * session.dispose();
358
358
  * }
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAIN,KAAK,8BAA8B,EACnC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAEN,KAAK,aAAa,EAMlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACN,KAAK,mBAAmB,EAIxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAGN,iBAAiB,EACjB,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC7B,qFAAqF;IACrF,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;OAIG;IACH,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC;;;;;;;;;OASG;IACH,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAA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,8BAA8B,EAC9B,aAAa,GAAG,cAAc,CAC9B;IACA;;;;;;;;;;OAUG;IACH,aAAa,EAAE,mBAAmB,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kDAAkD;IAClD,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AA0HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,sBAAsB,KAAG,eAqzBvE,CAAC"}
package/dist/session.js CHANGED
@@ -89,7 +89,7 @@ const arraysShallowEqual = (a, b) => {
89
89
  * const session = createAnalysisSession({sourceOptions, contextClosure: false});
90
90
  * try {
91
91
  * await session.setFiles(sourceFiles);
92
- * return session.query({onDuplicates: 'throw'});
92
+ * return session.query();
93
93
  * } finally {
94
94
  * session.dispose();
95
95
  * }
package/dist/vite.d.ts CHANGED
@@ -89,7 +89,7 @@ export interface VitePluginSvelteDocinfoOptions {
89
89
  * Partial overrides for default source options (SvelteKit `src/lib` layout).
90
90
  */
91
91
  sourceOptions?: SourceOptionsOverrides;
92
- /** Behavior when duplicate declaration names are found across modules. */
92
+ /** Opt-in check that declaration names are unique across modules (see `OnDuplicates`). */
93
93
  onDuplicates?: OnDuplicates;
94
94
  /**
95
95
  * Dev re-analysis debounce delay in milliseconds. Coalesces rapid file changes.
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,KAAK,EAAqC,MAAM,EAAiB,MAAM,MAAM,CAAC;AAGrF,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAuB,KAAK,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AC;IACrB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,0FAA0F;IAC1F,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,aAAa,GAAI,UAAS,8BAAmC,KAAG,MAodrE,CAAC;AAEF,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-docinfo",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "static analysis for TypeScript and Svelte",
5
5
  "glyph": "📜",
6
6
  "logo": "logo.svg",
@@ -61,11 +61,11 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@fuzdev/blake3-wasm": "^0.2.0",
64
- "@fuzdev/fuz_code": "^0.50.0",
64
+ "@fuzdev/fuz_code": "^0.52.1",
65
65
  "@fuzdev/fuz_css": "^0.66.1",
66
66
  "@fuzdev/fuz_ui": "^0.213.0",
67
67
  "@fuzdev/fuz_util": "^0.72.0",
68
- "@fuzdev/gro": "^0.215.1",
68
+ "@fuzdev/gro": "^0.216.0",
69
69
  "@fuzdev/mdz": "^0.4.0",
70
70
  "@ryanatkn/eslint-config": "^0.13.0",
71
71
  "@sveltejs/acorn-typescript": "^1.0.9",