svelte-docinfo 0.9.0 → 0.10.1

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
  *
@@ -1576,8 +1552,7 @@ export declare const finalizeDiagnostics: (diagnostics: Array<Diagnostic>, optio
1576
1552
  *
1577
1553
  * `message` gets the same treatment as `file`, by textual substitution. A
1578
1554
  * message is free-form, and not every path in one comes from a field this
1579
- * pass can see — `import_parse_failed` wraps an es-module-lexer error that
1580
- * embeds the file name itself. Scrubbing here means the contract holds for
1555
+ * pass can see — a wrapped error message can embed the file name itself. Scrubbing here means the contract holds for
1581
1556
  * the whole record rather than one field, so a producer can't reintroduce an
1582
1557
  * absolute path through prose.
1583
1558
  *
@@ -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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,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,aAAa,MAAM,KACjB,IAuBF,CAAC;AAiPF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,2BAA2B,GACvC,SAAS,KAAK,CAAC,UAAU,CAAC,EAC1B,SAAS,mBAAmB,EAC5B,SAAS,EAAE,CAAC,OAAO,KACjB,IAKF,CAAC"}
@@ -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
  *
@@ -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);
@@ -468,8 +447,7 @@ export const finalizeDiagnostics = (diagnostics, options) => {
468
447
  *
469
448
  * `message` gets the same treatment as `file`, by textual substitution. A
470
449
  * message is free-form, and not every path in one comes from a field this
471
- * pass can see — `import_parse_failed` wraps an es-module-lexer error that
472
- * embeds the file name itself. Scrubbing here means the contract holds for
450
+ * pass can see — a wrapped error message can embed the file name itself. Scrubbing here means the contract holds for
473
451
  * the whole record rather than one field, so a producer can't reintroduce an
474
452
  * absolute path through prose.
475
453
  *
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.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C9B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,OAAO,GAAU,SAAS,cAAc,KAAG,OAAO,CAAC,iBAAiB,CAwBhF,CAAC;AAIF;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACvC,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,0FAA0F;IAC1F,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,0DAA0D;IAC1D,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,SAAS,CAAC;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;AAUhD,4CAA4C;AAC5C,QAAA,MAAM,oBAAoB,4BAA6B,CAAC;AACxD,KAAK,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAS9D;;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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ACH,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
@@ -4,8 +4,6 @@
4
4
  * Exposes the `ImportResolver` token contract (`{resolve, identity, invalidate?}`) plus
5
5
  * building blocks the session uses inside its three-phase setFiles pipeline:
6
6
  *
7
- * - `ensureLexerReady` — one-time wasm init for `es-module-lexer`. Phase 1 is
8
- * sync per-file; the session awaits this once before the loop starts.
9
7
  * - `lexImports` — sync specifier extraction from already-prepared content
10
8
  * (raw TS/JS, or svelte2tsx virtual content for `.svelte` files).
11
9
  * - `createDefaultResolver` — the TS + tsconfig fallback used when neither
@@ -108,32 +106,29 @@ export type ResolveImport = ResolveImportFn | ImportResolver;
108
106
  * override.
109
107
  */
110
108
  export declare const normalizeResolveImport: (value: ResolveImport | undefined) => ImportResolver | undefined;
111
- /**
112
- * Ensure `es-module-lexer`'s wasm runtime is initialized.
113
- *
114
- * Idempotent and cheap after the first call. The session awaits this once at
115
- * the top of `setFiles` so phase 1's per-file lex is purely synchronous.
116
- */
117
- export declare const ensureLexerReady: () => Promise<void>;
118
109
  /**
119
110
  * Lex import specifiers from prepared content.
120
111
  *
121
- * Sync — caller must have awaited `ensureLexerReady` at least once before
122
- * invoking. For `.svelte` files, pass the svelte2tsx-transformed virtual
123
- * content, not the raw `.svelte` source (which isn't lex-able as JS/TS).
112
+ * Parses with TypeScript (`ts.createSourceFile`, no binding or checking)
113
+ * rather than lexing as JS, so TypeScript syntax a JS lexer misreads as a
114
+ * regex or comparison (`a! / b`, `Promise<Result<A, B>> => {}`) can't derail
115
+ * it, and every ES form is seen, including `export * as ns from` (which
116
+ * TypeScript's lighter `preProcessFile` scanner misses).
124
117
  *
125
- * Dynamic imports (`import(specifier)` with non-literal arg) are omitted.
126
- * `import type` and inline `type` specifiers are kept, but the lexer drops
127
- * type-only re-exports (`export type {...} from`, `export type * from`).
118
+ * Collects, in source order: static imports and re-exports (type-only ones
119
+ * included: `import type`, inline `type` specifiers, `export type {...}
120
+ * from`, `export type * from`), `import x = require()`, module augmentations
121
+ * (`declare module '…'` in a module), and anywhere in the file, dynamic
122
+ * `import()` with a string literal and `import('…')` types. CommonJS
123
+ * `require()` calls and non-literal `import()` are omitted.
128
124
  *
129
- * @throws Error if lexing fails (malformed source). Callers should catch and
130
- * emit `import_parse_failed`.
125
+ * For `.svelte` files, pass the svelte2tsx-transformed virtual content, not
126
+ * the raw `.svelte` source.
131
127
  *
132
128
  * @param content - prepared file content (TS/JS, or svelte2tsx virtual)
133
- * @param fileId - absolute file path (used for error messages)
134
- * @returns specifiers in declaration order
129
+ * @returns specifiers in source order
135
130
  */
136
- export declare const lexImports: (content: string, fileId: string) => Array<string>;
131
+ export declare const lexImports: (content: string) => Array<string>;
137
132
  /**
138
133
  * Whether a lexed specifier names a Node builtin (`fs`, `node:fs/promises`, …).
139
134
  *
@@ -1 +1 @@
1
- {"version":3,"file":"dep-resolver.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/dep-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG,CAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,KACZ,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5C;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC9B,uEAAuE;IACvE,OAAO,EAAE,eAAe,CAAC;IACzB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,cAAc,CAAC;AAE7D;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAClC,OAAO,aAAa,GAAG,SAAS,KAC9B,cAAc,GAAG,SAC6E,CAAC;AAElG;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,IAAI,CAErD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,KAAK,CAAC,MAAM,CAOxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,OAA+B,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C,MAAM,CAwCxD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,OAA+B,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,qBAAqB,GACjC,iBAAiB,EAAE,CAAC,eAAe,EACnC,aAAa,MAAM,EACnB,OAAM,EAAE,CAAC,oBAA6B,KACpC,cAgCF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAC7B,eAAe,eAAe,EAC9B,WAAU,MAAM,GAAG,MAA0B,KAC3C,cAGD,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,cAG5B,CAAC"}
@@ -4,8 +4,6 @@
4
4
  * Exposes the `ImportResolver` token contract (`{resolve, identity, invalidate?}`) plus
5
5
  * building blocks the session uses inside its three-phase setFiles pipeline:
6
6
  *
7
- * - `ensureLexerReady` — one-time wasm init for `es-module-lexer`. Phase 1 is
8
- * sync per-file; the session awaits this once before the loop starts.
9
7
  * - `lexImports` — sync specifier extraction from already-prepared content
10
8
  * (raw TS/JS, or svelte2tsx virtual content for `.svelte` files).
11
9
  * - `createDefaultResolver` — the TS + tsconfig fallback used when neither
@@ -32,7 +30,6 @@
32
30
  import { isBuiltin } from 'node:module';
33
31
  import { dirname, isAbsolute, resolve as resolvePath } from 'node:path';
34
32
  import ts from 'typescript';
35
- import { init as esModuleLexerInit, parse as esModuleLexerParse } from 'es-module-lexer';
36
33
  import { toPosixPath } from './paths.js';
37
34
  /**
38
35
  * Normalize the public `ResolveImport` union to an `ImportResolver`.
@@ -44,41 +41,64 @@ import { toPosixPath } from './paths.js';
44
41
  * override.
45
42
  */
46
43
  export const normalizeResolveImport = (value) => value === undefined ? undefined : typeof value === 'function' ? wrapResolveImport(value) : value;
47
- /**
48
- * Ensure `es-module-lexer`'s wasm runtime is initialized.
49
- *
50
- * Idempotent and cheap after the first call. The session awaits this once at
51
- * the top of `setFiles` so phase 1's per-file lex is purely synchronous.
52
- */
53
- export const ensureLexerReady = async () => {
54
- await esModuleLexerInit;
55
- };
56
44
  /**
57
45
  * Lex import specifiers from prepared content.
58
46
  *
59
- * Sync — caller must have awaited `ensureLexerReady` at least once before
60
- * invoking. For `.svelte` files, pass the svelte2tsx-transformed virtual
61
- * content, not the raw `.svelte` source (which isn't lex-able as JS/TS).
47
+ * Parses with TypeScript (`ts.createSourceFile`, no binding or checking)
48
+ * rather than lexing as JS, so TypeScript syntax a JS lexer misreads as a
49
+ * regex or comparison (`a! / b`, `Promise<Result<A, B>> => {}`) can't derail
50
+ * it, and every ES form is seen, including `export * as ns from` (which
51
+ * TypeScript's lighter `preProcessFile` scanner misses).
62
52
  *
63
- * Dynamic imports (`import(specifier)` with non-literal arg) are omitted.
64
- * `import type` and inline `type` specifiers are kept, but the lexer drops
65
- * type-only re-exports (`export type {...} from`, `export type * from`).
53
+ * Collects, in source order: static imports and re-exports (type-only ones
54
+ * included: `import type`, inline `type` specifiers, `export type {...}
55
+ * from`, `export type * from`), `import x = require()`, module augmentations
56
+ * (`declare module '…'` in a module), and anywhere in the file, dynamic
57
+ * `import()` with a string literal and `import('…')` types. CommonJS
58
+ * `require()` calls and non-literal `import()` are omitted.
66
59
  *
67
- * @throws Error if lexing fails (malformed source). Callers should catch and
68
- * emit `import_parse_failed`.
60
+ * For `.svelte` files, pass the svelte2tsx-transformed virtual content, not
61
+ * the raw `.svelte` source.
69
62
  *
70
63
  * @param content - prepared file content (TS/JS, or svelte2tsx virtual)
71
- * @param fileId - absolute file path (used for error messages)
72
- * @returns specifiers in declaration order
64
+ * @returns specifiers in source order
73
65
  */
74
- export const lexImports = (content, fileId) => {
75
- const [imports] = esModuleLexerParse(content, fileId);
76
- const specifiers = [];
77
- for (const imp of imports) {
78
- if (imp.n)
79
- specifiers.push(imp.n);
66
+ export const lexImports = (content) => {
67
+ const sourceFile = ts.createSourceFile('lex.ts', content, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
68
+ const found = [];
69
+ const add = (node) => {
70
+ if (node && ts.isStringLiteralLike(node))
71
+ found.push({ pos: node.pos, text: node.text });
72
+ };
73
+ const isModule = ts.isExternalModule(sourceFile);
74
+ for (const statement of sourceFile.statements) {
75
+ if (ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) {
76
+ add(statement.moduleSpecifier);
77
+ }
78
+ else if (ts.isImportEqualsDeclaration(statement) &&
79
+ ts.isExternalModuleReference(statement.moduleReference)) {
80
+ add(statement.moduleReference.expression);
81
+ }
82
+ else if (isModule && ts.isModuleDeclaration(statement)) {
83
+ add(statement.name);
84
+ }
85
+ }
86
+ // dynamic imports and import types can sit at any depth, so the full walk
87
+ // runs only when the text could contain one
88
+ if (content.includes('import(') || content.includes('import (')) {
89
+ const visit = (node) => {
90
+ if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
91
+ add(node.arguments[0]);
92
+ }
93
+ else if (ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument)) {
94
+ add(node.argument.literal);
95
+ }
96
+ ts.forEachChild(node, visit);
97
+ };
98
+ visit(sourceFile);
99
+ found.sort((a, b) => a.pos - b.pos);
80
100
  }
81
- return specifiers;
101
+ return found.map((f) => f.text);
82
102
  };
83
103
  /**
84
104
  * Whether a lexed specifier names a Node builtin (`fs`, `node:fs/promises`, …).
@@ -455,7 +455,10 @@ export declare const ModuleUnreadableDiagnostic: z.ZodObject<{
455
455
  }, z.core.$strict>;
456
456
  export type ModuleUnreadableDiagnostic = z.infer<typeof ModuleUnreadableDiagnostic>;
457
457
  /**
458
- * Import parsing failed during dependency resolution.
458
+ * Import scanning threw during dependency resolution.
459
+ *
460
+ * Not expected in practice: the parse in `lexImports` tolerates malformed
461
+ * source rather than rejecting it, so this guards an unexpected throw.
459
462
  */
460
463
  export declare const ImportParseDiagnostic: z.ZodObject<{
461
464
  /**
@@ -677,11 +680,11 @@ export type UnknownParamDiagnostic = z.infer<typeof UnknownParamDiagnostic>;
677
680
  /**
678
681
  * A declaration `name` appears in more than one module.
679
682
  *
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.
683
+ * Opt-in: emitted only when `onDuplicates` is set, for packages that keep a
684
+ * flat export namespace (see `OnDuplicates`). Emitted at `warning` severity
685
+ * so the analysis result remains usable; `onDuplicates: 'throw'` makes it
686
+ * fatal. The default slot (`name === 'default'`) is excluded — every module
687
+ * owns its own.
685
688
  */
686
689
  export declare const DuplicateDeclarationDiagnostic: z.ZodObject<{
687
690
  /** The duplicated declaration name. */
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;EAA+B,CAAC;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;EAiBzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAgD5D;;GAEG;AACH,eAAO,MAAM,wBAAwB;IAGpC,2DAA2D;;IAzC3D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;IAEH,6DAA6D;;IAE7D,+DAA+D;;IAE/D,+CAA+C;;;;;;;kBAa9C,CAAC;AACH,MAAM,MAAM,wBAAwB,G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EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAC6C,CAAC;AAEvF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU,KAAG,MAMzD,CAAC"}
@@ -240,7 +240,10 @@ export const ModuleUnreadableDiagnostic = z.strictObject({
240
240
  ...baseDiagnosticFields
241
241
  });
242
242
  /**
243
- * Import parsing failed during dependency resolution.
243
+ * Import scanning threw during dependency resolution.
244
+ *
245
+ * Not expected in practice: the parse in `lexImports` tolerates malformed
246
+ * source rather than rejecting it, so this guards an unexpected throw.
244
247
  */
245
248
  export const ImportParseDiagnostic = z.strictObject({
246
249
  kind: z.literal('import_parse_failed'),
@@ -315,11 +318,11 @@ export const UnknownParamDiagnostic = z.strictObject({
315
318
  /**
316
319
  * A declaration `name` appears in more than one module.
317
320
  *
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.
321
+ * Opt-in: emitted only when `onDuplicates` is set, for packages that keep a
322
+ * flat export namespace (see `OnDuplicates`). Emitted at `warning` severity
323
+ * so the analysis result remains usable; `onDuplicates: 'throw'` makes it
324
+ * fatal. The default slot (`name === 'default'`) is excluded — every module
325
+ * owns its own.
323
326
  */
324
327
  export const DuplicateDeclarationDiagnostic = z.strictObject({
325
328
  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;;;;;;;;;GASG;AAIH,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EACX,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,cA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BAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,MAAM,YAAY,CAAC;AAIpB,OAAO,EACN,cAAc,EACd,cAAc,EACd,eAAe,EACf,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjF,YAAY,EACX,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACjG,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EACX,SAAS,EACT,0BAA0B,EAC1B,yBAAyB,EACzB,MAAM,gBAAgB,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,KAAK,CAAC,UAAU,CAExE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,KAAK,CAAC,UAAU,CAAC,KAAG,KAAK,CAAC,UAAU,CAsC3E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,uBAAuB,GACnC,SAAS,KAAK,CAAC,UAAU,CAAC,EAC1B,iBAAgB,aAAa,CAAC,UAAU,CAAM,KAC5C,KAAK,CAAC,UAAU,CA4DlB,CAAC;AAEF;;;;;;;;;;;;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;IACb;;;;OAIG;IACH,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IACtD,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,oFAAoF;IACpF,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACnC;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,KAAK,CAAC,UAAU,CAAC,EAC1B,MAAM,MAAM,KACV,aAAa,GAAG,IA+IlB,CAAC"}
@@ -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
@@ -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,EA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B,KAAG,eAozBvE,CAAC"}
package/dist/session.js CHANGED
@@ -40,7 +40,7 @@ import ts from 'typescript';
40
40
  import { createAnalysisLanguageService, createOwnedDirIndex } from './typescript-program.js';
41
41
  import { toErrorMessage } from './error.js';
42
42
  import { transformSvelteSource } from './svelte.js';
43
- import { createDefaultResolver, ensureLexerReady, isNodeBuiltin, lexImports, normalizeResolveImport } from './dep-resolver.js';
43
+ import { createDefaultResolver, isNodeBuiltin, lexImports, normalizeResolveImport } from './dep-resolver.js';
44
44
  import { hasBaselineExcludedSegment, isSource, normalizeSourceOptions } from './source-config.js';
45
45
  import { toPosixPath } from './paths.js';
46
46
  import { MAX_FILE_CONCURRENCY, MAX_RESOLVE_CONCURRENCY, mapConcurrent } from './concurrency.js';
@@ -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
  * }
@@ -247,15 +247,16 @@ export const createAnalysisSession = (options) => {
247
247
  }
248
248
  }
249
249
  // Lex import specifiers — skipped when caller supplied pre-resolved deps.
250
- // Sync — caller awaited ensureLexerReady. CSS/JSON files have nothing to
251
- // lex; transform_failed Svelte has no virtual content to lex.
250
+ // CSS/JSON files have nothing to lex; transform_failed Svelte has no
251
+ // virtual content to lex. The parse tolerates malformed source, so the
252
+ // catch only guards an unexpected throw.
252
253
  let specifiers = [];
253
254
  if (!usePreResolved &&
254
255
  !transformFailed &&
255
256
  (analyzer === 'typescript' || analyzer === 'svelte')) {
256
257
  try {
257
258
  const contentToLex = virtual ? virtual.content : file.content;
258
- specifiers = lexImports(contentToLex, file.id);
259
+ specifiers = lexImports(contentToLex);
259
260
  }
260
261
  catch (err) {
261
262
  ingestDiagnostics.push({
@@ -393,7 +394,6 @@ export const createAnalysisSession = (options) => {
393
394
  // batch's posixified resolved import targets before any `isSource`
394
395
  // filtering — the context-closure seed; never stored on entries.
395
396
  const runBatch = async (files, opts) => {
396
- await ensureLexerReady();
397
397
  // Resolver gating: pick one only if any file in the batch lacks
398
398
  // `dependencies` (i.e., needs lex+resolve). For fully pre-resolved
399
399
  // batches the resolver is never consulted, so we skip `pickResolver`
package/dist/source.d.ts CHANGED
@@ -59,12 +59,10 @@ export interface SourceFileInfo {
59
59
  * supply this field own the correctness of the graph they hand over.
60
60
  *
61
61
  * Type-only imports (`import type {...}`) are the most common asymmetry
62
- * versus the lex+resolve path: the default lex (`es-module-lexer`) keeps
63
- * `import type` and inline `type` specifiers; pre-resolved callers backed
64
- * by a Gro-style filer typically drop them. Both are intentional within
65
- * their respective contracts. The default lex does drop type-only
66
- * re-exports (see `lexImports`), so such a re-export has a `reExports`
67
- * edge with no `dependencies` entry and seeds no context closure.
62
+ * versus the lex+resolve path: the default lex (`lexImports`) keeps
63
+ * type-only imports and re-exports; pre-resolved callers backed by a
64
+ * Gro-style filer typically drop them. Both are intentional within their
65
+ * respective contracts.
68
66
  *
69
67
  * Cache semantics: the session compares this array element-wise (shallow
70
68
  * equality) against the snapshot stored from the prior call — a fresh
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEpE;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC9B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,k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velteDocinfoOptions {
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,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKrE,OAAO,EAGN,KAAK,aAAa,EAElB,KAAK,sBAAsB,EAC3B,MAAM,oBAAoB,CAAC;AAU5B,mDAAmD;AACnD,MAAM,WAAW,8BAA8B;IAC9C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;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,0EAA0E;IAC1E,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"}
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,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKrE,OAAO,EAGN,KAAK,aAAa,EAElB,KAAK,sBAAsB,EAC3B,MAAM,oBAAoB,CAAC;AAU5B,mDAAmD;AACnD,MAAM,WAAW,8BAA8B;IAC9C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;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.1",
4
4
  "description": "static analysis for TypeScript and Svelte",
5
5
  "glyph": "📜",
6
6
  "logo": "logo.svg",
@@ -43,7 +43,6 @@
43
43
  "dependencies": {
44
44
  "@jridgewell/trace-mapping": "^0.3.25",
45
45
  "commander": "^14.0.3",
46
- "es-module-lexer": "^2.0.0",
47
46
  "picomatch": "^4.0.4",
48
47
  "tinyglobby": "^0.2.15"
49
48
  },
@@ -61,11 +60,11 @@
61
60
  },
62
61
  "devDependencies": {
63
62
  "@fuzdev/blake3-wasm": "^0.2.0",
64
- "@fuzdev/fuz_code": "^0.50.0",
63
+ "@fuzdev/fuz_code": "^0.52.1",
65
64
  "@fuzdev/fuz_css": "^0.66.1",
66
65
  "@fuzdev/fuz_ui": "^0.213.0",
67
66
  "@fuzdev/fuz_util": "^0.72.0",
68
- "@fuzdev/gro": "^0.215.1",
67
+ "@fuzdev/gro": "^0.216.0",
69
68
  "@fuzdev/mdz": "^0.4.0",
70
69
  "@ryanatkn/eslint-config": "^0.13.0",
71
70
  "@sveltejs/acorn-typescript": "^1.0.9",