svelte-docinfo 0.5.4 → 0.6.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.
Files changed (90) hide show
  1. package/README.md +69 -50
  2. package/dist/analyze-core.d.ts +179 -24
  3. package/dist/analyze-core.d.ts.map +1 -1
  4. package/dist/analyze-core.js +462 -42
  5. package/dist/analyze.d.ts +31 -6
  6. package/dist/analyze.d.ts.map +1 -1
  7. package/dist/analyze.js +29 -9
  8. package/dist/cli.d.ts +17 -7
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +12 -9
  11. package/dist/declaration-build.d.ts +14 -4
  12. package/dist/declaration-build.d.ts.map +1 -1
  13. package/dist/declaration-helpers.d.ts +65 -42
  14. package/dist/declaration-helpers.d.ts.map +1 -1
  15. package/dist/declaration-helpers.js +167 -72
  16. package/dist/dep-resolver.d.ts +38 -13
  17. package/dist/dep-resolver.d.ts.map +1 -1
  18. package/dist/dep-resolver.js +40 -22
  19. package/dist/diagnostics.d.ts +365 -14
  20. package/dist/diagnostics.d.ts.map +1 -1
  21. package/dist/diagnostics.js +112 -28
  22. package/dist/discovery.d.ts +7 -2
  23. package/dist/discovery.d.ts.map +1 -1
  24. package/dist/discovery.js +11 -5
  25. package/dist/exports.d.ts +39 -2
  26. package/dist/exports.d.ts.map +1 -1
  27. package/dist/exports.js +251 -46
  28. package/dist/files.d.ts +14 -2
  29. package/dist/files.d.ts.map +1 -1
  30. package/dist/files.js +49 -8
  31. package/dist/index.d.ts +9 -7
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +6 -4
  34. package/dist/logo.js +3 -3
  35. package/dist/paths.d.ts +22 -1
  36. package/dist/paths.d.ts.map +1 -1
  37. package/dist/paths.js +22 -1
  38. package/dist/postprocess.d.ts +31 -10
  39. package/dist/postprocess.d.ts.map +1 -1
  40. package/dist/postprocess.js +124 -76
  41. package/dist/session.d.ts +101 -11
  42. package/dist/session.d.ts.map +1 -1
  43. package/dist/session.js +457 -127
  44. package/dist/source-config.d.ts +210 -33
  45. package/dist/source-config.d.ts.map +1 -1
  46. package/dist/source-config.js +313 -26
  47. package/dist/source.d.ts +35 -0
  48. package/dist/source.d.ts.map +1 -1
  49. package/dist/source.js +37 -0
  50. package/dist/svelte.d.ts +81 -23
  51. package/dist/svelte.d.ts.map +1 -1
  52. package/dist/svelte.js +686 -359
  53. package/dist/tsdoc.d.ts +47 -12
  54. package/dist/tsdoc.d.ts.map +1 -1
  55. package/dist/tsdoc.js +70 -17
  56. package/dist/types.d.ts +967 -45
  57. package/dist/types.d.ts.map +1 -1
  58. package/dist/types.js +259 -48
  59. package/dist/typescript-alias-registry.d.ts +76 -0
  60. package/dist/typescript-alias-registry.d.ts.map +1 -0
  61. package/dist/typescript-alias-registry.js +206 -0
  62. package/dist/typescript-exports.d.ts +20 -15
  63. package/dist/typescript-exports.d.ts.map +1 -1
  64. package/dist/typescript-exports.js +264 -137
  65. package/dist/typescript-extract-class.d.ts +3 -4
  66. package/dist/typescript-extract-class.d.ts.map +1 -1
  67. package/dist/typescript-extract-class.js +71 -52
  68. package/dist/typescript-extract-function.d.ts +6 -8
  69. package/dist/typescript-extract-function.d.ts.map +1 -1
  70. package/dist/typescript-extract-function.js +20 -15
  71. package/dist/typescript-extract-shared.d.ts +309 -29
  72. package/dist/typescript-extract-shared.d.ts.map +1 -1
  73. package/dist/typescript-extract-shared.js +957 -127
  74. package/dist/typescript-extract-type-json.d.ts +286 -0
  75. package/dist/typescript-extract-type-json.d.ts.map +1 -0
  76. package/dist/typescript-extract-type-json.js +854 -0
  77. package/dist/typescript-extract-type-properties.d.ts +2 -3
  78. package/dist/typescript-extract-type-properties.d.ts.map +1 -1
  79. package/dist/typescript-extract-type-properties.js +91 -84
  80. package/dist/typescript-extract-type.d.ts +6 -8
  81. package/dist/typescript-extract-type.d.ts.map +1 -1
  82. package/dist/typescript-extract-type.js +138 -40
  83. package/dist/typescript-program.d.ts +106 -23
  84. package/dist/typescript-program.d.ts.map +1 -1
  85. package/dist/typescript-program.js +182 -54
  86. package/dist/vite.d.ts +23 -8
  87. package/dist/vite.d.ts.map +1 -1
  88. package/dist/vite.js +34 -14
  89. package/package.json +17 -15
  90. package/virtual-svelte-docinfo.d.ts +1 -1
@@ -51,9 +51,14 @@
51
51
  * ## File Path Contract
52
52
  *
53
53
  * `Diagnostic.file` is always project-root-relative — no leading slash,
54
- * no `./` prefix. `analyze` / `analyzeFromFiles` normalize paths from all
55
- * sources (extraction, discovery, dependency resolution) before returning.
56
- * Consumers that need an absolute path can rejoin with `projectRoot`.
54
+ * no `./` prefix. `analyze` / `analyzeFromFiles` and the session
55
+ * (`setFile`/`setFiles` at ingest, `query` at analysis) normalize paths from
56
+ * all sources (extraction, discovery, dependency resolution) before
57
+ * returning. Consumers that need an absolute path can rejoin with
58
+ * `projectRoot`.
59
+ *
60
+ * It names a *file*, not a module: `ModuleJson.path` is relative to
61
+ * `sourceRoot`, so `file` is not a lookup key into `modules`.
57
62
  *
58
63
  * @module
59
64
  */
@@ -75,6 +80,7 @@ export const DiagnosticKind = z.enum([
75
80
  'signature_analysis_failed',
76
81
  'class_member_failed',
77
82
  'svelte_prop_failed',
83
+ 'legacy_props',
78
84
  'module_skipped',
79
85
  'module_unreadable',
80
86
  'import_parse_failed',
@@ -85,6 +91,7 @@ export const DiagnosticKind = z.enum([
85
91
  'duplicate_declaration',
86
92
  'transform_failed',
87
93
  'resolver_failed',
94
+ 'alias_lost'
88
95
  ]);
89
96
  // Variants
90
97
  /**
@@ -105,6 +112,21 @@ const baseDiagnosticFields = {
105
112
  * pipeline may write absolute or virtual paths (e.g.,
106
113
  * `Foo.svelte.__svelte2tsx__.ts`); normalization rewrites them to
107
114
  * project-relative form before they reach consumers.
115
+ *
116
+ * The exception is **discovery** — `discoverSourceFiles` /
117
+ * `discoverFromExports` return their diagnostics unnormalized, since they
118
+ * run before any session exists. Their `file` is already
119
+ * project-root-relative, but `message` can embed an absolute path (an fs
120
+ * error names the file it failed on), so a consumer wiring discovery up
121
+ * itself owns the `normalizeDiagnosticPaths` call — `analyzeFromFiles` and
122
+ * the Vite plugin both make it before merging.
123
+ *
124
+ * **The absolute form is the one to write.** Normalization deliberately
125
+ * leaves an already-relative path alone (relativizing it would resolve
126
+ * against `cwd`), so a producer writing a `ModuleJson.path` — relative to
127
+ * `sourceRoot`, a different base — passes through untouched and publishes
128
+ * the same file under a second name. Absolute is what the pass can
129
+ * actually correct.
108
130
  */
109
131
  file: z.string(),
110
132
  /** Line number (1-based), absent if location unavailable. */
@@ -113,7 +135,7 @@ const baseDiagnosticFields = {
113
135
  column: z.number().int().positive().optional(),
114
136
  /** Human-readable description of the issue. */
115
137
  message: z.string(),
116
- severity: DiagnosticSeverity,
138
+ severity: DiagnosticSeverity
117
139
  };
118
140
  /**
119
141
  * Type extraction failed (e.g., complex or recursive types).
@@ -122,7 +144,7 @@ export const TypeExtractionDiagnostic = z.strictObject({
122
144
  kind: z.literal('type_extraction_failed'),
123
145
  ...baseDiagnosticFields,
124
146
  /** Name of the symbol whose type couldn't be extracted. */
125
- symbolName: z.string(),
147
+ symbolName: z.string()
126
148
  });
127
149
  /**
128
150
  * Function/method signature analysis failed.
@@ -131,7 +153,7 @@ export const SignatureAnalysisDiagnostic = z.strictObject({
131
153
  kind: z.literal('signature_analysis_failed'),
132
154
  ...baseDiagnosticFields,
133
155
  /** Name of the function or method. */
134
- functionName: z.string(),
156
+ functionName: z.string()
135
157
  });
136
158
  /**
137
159
  * Class member analysis failed.
@@ -142,10 +164,17 @@ export const ClassMemberDiagnostic = z.strictObject({
142
164
  /** Name of the class. */
143
165
  className: z.string(),
144
166
  /** Name of the member that failed. */
145
- memberName: z.string(),
167
+ memberName: z.string()
146
168
  });
147
169
  /**
148
170
  * Svelte prop type resolution failed.
171
+ *
172
+ * `file` is the original `.svelte` path, so `line`/`column` are present only
173
+ * when the prop's declaration lives in the component's own virtual *and* maps
174
+ * back to the original source — an imported props type or a node svelte2tsx
175
+ * synthesized leaves the position absent rather than publishing a virtual
176
+ * line, the rule `remapVirtualDiagnosticPositions` applies to extractor
177
+ * diagnostics.
149
178
  */
150
179
  export const SveltePropDiagnostic = z.strictObject({
151
180
  kind: z.literal('svelte_prop_failed'),
@@ -153,7 +182,25 @@ export const SveltePropDiagnostic = z.strictObject({
153
182
  /** Name of the component. */
154
183
  componentName: z.string(),
155
184
  /** Name of the prop. */
156
- propName: z.string(),
185
+ propName: z.string()
186
+ });
187
+ /**
188
+ * Legacy (runes-less) component props detected — not extracted.
189
+ *
190
+ * `export let` components are still-legal Svelte 5 syntax, but prop extraction
191
+ * anchors on the `$props()` declaration, so their props yield no
192
+ * `ComponentPropJson` entries. Emitted once per component, listing the
193
+ * detected prop names — exported `let`/`var` statements plus export-clause
194
+ * renames of mutable bindings (`export {a as b}`) — with `line` pointing at
195
+ * the first legacy prop export in the original `.svelte` source.
196
+ */
197
+ export const LegacyPropsDiagnostic = z.strictObject({
198
+ kind: z.literal('legacy_props'),
199
+ ...baseDiagnosticFields,
200
+ /** Name of the component. */
201
+ componentName: z.string(),
202
+ /** Exported prop names, in source order. */
203
+ propNames: z.array(z.string()).min(1)
157
204
  });
158
205
  /**
159
206
  * Module was skipped during the analysis pass.
@@ -173,7 +220,7 @@ export const ModuleSkippedDiagnostic = z.strictObject({
173
220
  kind: z.literal('module_skipped'),
174
221
  ...baseDiagnosticFields,
175
222
  /** Reason the module was skipped. */
176
- reason: z.enum(['not_in_program', 'no_analyzer', 'requires_program']),
223
+ reason: z.enum(['not_in_program', 'no_analyzer', 'requires_program'])
177
224
  });
178
225
  /**
179
226
  * File discovered via package.json `exports` exists but couldn't be read.
@@ -185,14 +232,14 @@ export const ModuleSkippedDiagnostic = z.strictObject({
185
232
  */
186
233
  export const ModuleUnreadableDiagnostic = z.strictObject({
187
234
  kind: z.literal('module_unreadable'),
188
- ...baseDiagnosticFields,
235
+ ...baseDiagnosticFields
189
236
  });
190
237
  /**
191
238
  * Import parsing failed during dependency resolution.
192
239
  */
193
240
  export const ImportParseDiagnostic = z.strictObject({
194
241
  kind: z.literal('import_parse_failed'),
195
- ...baseDiagnosticFields,
242
+ ...baseDiagnosticFields
196
243
  });
197
244
  /**
198
245
  * Duplicate comment sources detected (e.g., both HTML and JSDoc `@module`,
@@ -202,7 +249,7 @@ export const DuplicateCommentDiagnostic = z.strictObject({
202
249
  kind: z.literal('duplicate_comment'),
203
250
  ...baseDiagnosticFields,
204
251
  /** Which comment type is duplicated. */
205
- commentType: z.enum(['module_comment', 'doc_comment']),
252
+ commentType: z.enum(['module_comment', 'doc_comment'])
206
253
  });
207
254
  /**
208
255
  * A JSDoc tag found somewhere it has no effect.
@@ -210,8 +257,9 @@ export const DuplicateCommentDiagnostic = z.strictObject({
210
257
  * Two contexts emit this:
211
258
  *
212
259
  * - **Non-primary overload signature** — symbol-scope tags (`@example`,
213
- * `@deprecated`, `@since`, `@see`, `@throws`, `@mutates`, `@default`,
214
- * `@nodocs`) describe the function as a whole, not individual signatures.
260
+ * `@deprecated`, `@internal`, `@since`, `@see`, `@throws`, `@mutates`,
261
+ * `@default`, `@nodocs`) describe the function as a whole, not individual
262
+ * signatures.
215
263
  * The primary signature's JSDoc feeds the parent declaration's symbol-level
216
264
  * extraction; tags on non-primary overload signatures are silently dropped
217
265
  * from output. This diagnostic surfaces them so authors can move them to
@@ -230,18 +278,20 @@ export const MisplacedTagDiagnostic = z.strictObject({
230
278
  tagName: z.enum([
231
279
  'example',
232
280
  'deprecated',
281
+ 'internal',
233
282
  'since',
234
283
  'see',
235
284
  'throws',
236
285
  'mutates',
237
286
  'default',
238
- 'nodocs',
287
+ 'nodocs'
239
288
  ]),
240
289
  /**
241
- * Name of the function or method whose overload carries the misplaced tag.
242
- * Absent for module-comment misplacements (no enclosing symbol).
290
+ * Name of the enclosing symbol: the function or method whose overload
291
+ * carries the misplaced tag. Absent for module-comment misplacements (no
292
+ * enclosing symbol).
243
293
  */
244
- functionName: z.string().optional(),
294
+ functionName: z.string().optional()
245
295
  });
246
296
  /**
247
297
  * `@param` tag references a name that doesn't match any actual parameter.
@@ -255,7 +305,7 @@ export const UnknownParamDiagnostic = z.strictObject({
255
305
  /** The `@param` key that didn't match a real parameter. */
256
306
  paramName: z.string(),
257
307
  /** Name of the function or method. */
258
- functionName: z.string(),
308
+ functionName: z.string()
259
309
  });
260
310
  /**
261
311
  * A declaration `name` appears in more than one module.
@@ -271,16 +321,25 @@ export const DuplicateDeclarationDiagnostic = z.strictObject({
271
321
  ...baseDiagnosticFields,
272
322
  /** The duplicated declaration name. */
273
323
  declarationName: z.string(),
274
- /** Module paths where the name was defined (>= 2). */
275
- modules: z.array(z.string()).min(2),
324
+ /**
325
+ * Module paths where the name was defined (>= 2).
326
+ *
327
+ * `ModuleJson.path` values — relative to `sourceRoot`, so a different base
328
+ * than the record's `file` (project-root-relative, like every diagnostic).
329
+ * The two disagree textually whenever `sourceRoot` is non-empty; each names
330
+ * what it says it names, a module vs. a file.
331
+ */
332
+ modules: z.array(z.string()).min(2)
276
333
  });
277
334
  /**
278
335
  * Source map parsing failed for a Svelte virtual file.
279
336
  *
280
- * Analysis continues using virtual-file positions, so downstream `line`/`column`
281
- * fields on other diagnostics may point into the svelte2tsx-generated TS rather
282
- * than the original `.svelte` source. Rare; usually signals a malformed or
283
- * incompatible svelte2tsx output.
337
+ * Analysis continues without position mapping: query-time diagnostics drop
338
+ * `line`/`column` rather than point into svelte2tsx-generated TS — those
339
+ * emitted against the virtual via `remapVirtualDiagnosticPositions`,
340
+ * `svelte_prop_failed` at its own emission site — while declaration
341
+ * `sourceLine`s fall back to virtual positions. Rare; usually signals a
342
+ * malformed or incompatible svelte2tsx output.
284
343
  *
285
344
  * Emitted at ingest time by `transformSvelteSource` (in `svelte.ts`); flows
286
345
  * through `setFile`/`setFiles` ingest diagnostics rather than the analysis
@@ -288,7 +347,7 @@ export const DuplicateDeclarationDiagnostic = z.strictObject({
288
347
  */
289
348
  export const SourceMapFailedDiagnostic = z.strictObject({
290
349
  kind: z.literal('source_map_failed'),
291
- ...baseDiagnosticFields,
350
+ ...baseDiagnosticFields
292
351
  });
293
352
  /**
294
353
  * svelte2tsx transform threw for a `.svelte` file.
@@ -301,7 +360,7 @@ export const SourceMapFailedDiagnostic = z.strictObject({
301
360
  */
302
361
  export const TransformFailedDiagnostic = z.strictObject({
303
362
  kind: z.literal('transform_failed'),
304
- ...baseDiagnosticFields,
363
+ ...baseDiagnosticFields
305
364
  });
306
365
  /**
307
366
  * Import resolver threw while resolving a specifier.
@@ -318,7 +377,30 @@ export const ResolverFailedDiagnostic = z.strictObject({
318
377
  kind: z.literal('resolver_failed'),
319
378
  ...baseDiagnosticFields,
320
379
  /** The import specifier the resolver failed on. */
321
- specifier: z.string(),
380
+ specifier: z.string()
381
+ });
382
+ /**
383
+ * An exported type alias loses its name at use sites.
384
+ *
385
+ * The alias's right-hand side (an indexed access or conditional —
386
+ * `z.infer<typeof S>`, valibot's `InferOutput`) resolves to a pre-existing
387
+ * interned type that TypeScript never retroactively stamps an alias symbol
388
+ * on, so unannotated positions document the expansion instead of the name.
389
+ * Fires only where nothing self-heals: a loss the alias registry recovers
390
+ * (`typeInfo` emits `{kind: 'reference', name}` at use sites) is suppressed,
391
+ * as are literal-only unions (`z.enum` outputs) and brand-like intersections
392
+ * (`.brand()`) — readable degradations with no author-side fix worth
393
+ * demanding. `@nodocs` on the declaration suppresses. The author-side escape
394
+ * for a flagged alias is a nominal symbol, e.g.
395
+ * `interface Foo extends z.infer<typeof S> {}` where applicable.
396
+ *
397
+ * Always `warning`, query-time category (recomputed each `query()`).
398
+ */
399
+ export const AliasLostDiagnostic = z.strictObject({
400
+ kind: z.literal('alias_lost'),
401
+ ...baseDiagnosticFields,
402
+ /** Name of the alias whose right-hand side resolves to a nameless type. */
403
+ aliasName: z.string()
322
404
  });
323
405
  /**
324
406
  * Discriminated union of all diagnostic variants.
@@ -328,6 +410,7 @@ export const Diagnostic = z.discriminatedUnion('kind', [
328
410
  SignatureAnalysisDiagnostic,
329
411
  ClassMemberDiagnostic,
330
412
  SveltePropDiagnostic,
413
+ LegacyPropsDiagnostic,
331
414
  ModuleSkippedDiagnostic,
332
415
  ModuleUnreadableDiagnostic,
333
416
  ImportParseDiagnostic,
@@ -338,6 +421,7 @@ export const Diagnostic = z.discriminatedUnion('kind', [
338
421
  DuplicateDeclarationDiagnostic,
339
422
  TransformFailedDiagnostic,
340
423
  ResolverFailedDiagnostic,
424
+ AliasLostDiagnostic
341
425
  ]);
342
426
  // Helpers
343
427
  /**
@@ -45,7 +45,9 @@ export interface DiscoverSourceFilesOptions {
45
45
  */
46
46
  sourceOptions: ModuleSourceOptions;
47
47
  /**
48
- * Glob patterns to include (relative to `projectRoot`).
48
+ * Glob patterns to include (relative to `projectRoot`; an absolute pattern
49
+ * inside the root relativizes, an out-of-root one throws — see
50
+ * `normalizeIncludePatterns`).
49
51
  *
50
52
  * Filter for glob-based discovery. When `discovery` is `'auto'` (default),
51
53
  * providing `include` collapses the chain to glob immediately. Combining
@@ -97,7 +99,10 @@ export interface DiscoverSourceFilesResult {
97
99
  * - `'glob'` — glob only; `include` parameterizes the search.
98
100
  *
99
101
  * Exclusion globs come from `sourceOptions.exclude` (the single source of
100
- * truth, also applied at analysis time by `isSource()`).
102
+ * truth, also applied at analysis time by `isSource()`). Beneath it, the
103
+ * always-on baseline (`node_modules` + dot-directories, see
104
+ * `hasBaselineExcludedSegment` in `source-config.ts`) applies at both stages
105
+ * and is not affected by `exclude` overrides.
101
106
  *
102
107
  * @param options - discovery configuration
103
108
  * @returns discovered files (content loaded) and any diagnostics from the exports step
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,KAAK,mBAAmB,EAAgB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,KAAK,EAAC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AAS,GAAG,MAAM,CAAC;AAEpD,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IAC1C;;;;;;;;;OASG;IACH,aAAa,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AAED,uCAAuC;AACvC,MAAM,WAAW,yBAAyB;IACzC,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC7B,qFAAqF;IACrF,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,0BAA0B,KACjC,OAAO,CAAC,yBAAyB,CAmGnC,CAAC"}
package/dist/discovery.js CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * @module
12
12
  */
13
- import { getSourceRoot } from './source-config.js';
13
+ import { getSourceRoot, normalizeIncludePatterns } from './source-config.js';
14
14
  import { globFiles, deriveIncludePatterns } from './files.js';
15
15
  import { discoverFromExports } from './exports.js';
16
16
  /**
@@ -28,7 +28,10 @@ import { discoverFromExports } from './exports.js';
28
28
  * - `'glob'` — glob only; `include` parameterizes the search.
29
29
  *
30
30
  * Exclusion globs come from `sourceOptions.exclude` (the single source of
31
- * truth, also applied at analysis time by `isSource()`).
31
+ * truth, also applied at analysis time by `isSource()`). Beneath it, the
32
+ * always-on baseline (`node_modules` + dot-directories, see
33
+ * `hasBaselineExcludedSegment` in `source-config.ts`) applies at both stages
34
+ * and is not affected by `exclude` overrides.
32
35
  *
33
36
  * @param options - discovery configuration
34
37
  * @returns discovered files (content loaded) and any diagnostics from the exports step
@@ -43,8 +46,11 @@ import { discoverFromExports } from './exports.js';
43
46
  * ```
44
47
  */
45
48
  export const discoverSourceFiles = async (options) => {
46
- const { sourceOptions, include, discovery = 'auto', distDir, log } = options;
49
+ const { sourceOptions, discovery = 'auto', distDir, log } = options;
47
50
  const { projectRoot, exclude } = sourceOptions;
51
+ // In-root absolute patterns relativize (out-of-root throws) so the glob
52
+ // and its anchored baseline ignores see projectRoot-relative patterns.
53
+ const include = options.include && normalizeIncludePatterns(options.include, projectRoot);
48
54
  // Reject contradictory configurations early. `include` parameterizes glob,
49
55
  // so combining it with strict `'exports'` is a user error rather than a
50
56
  // silent override.
@@ -84,7 +90,7 @@ export const discoverSourceFiles = async (options) => {
84
90
  projectRoot,
85
91
  exclude,
86
92
  sourceDir,
87
- distDir,
93
+ distDir
88
94
  });
89
95
  const { files: exportsFiles, diagnostics: exportsDiagnostics } = exportsResult;
90
96
  diagnostics = exportsDiagnostics;
@@ -118,7 +124,7 @@ export const discoverSourceFiles = async (options) => {
118
124
  files = await globFiles({
119
125
  projectRoot,
120
126
  include: include ?? deriveIncludePatterns(sourceOptions.sourcePaths),
121
- exclude,
127
+ exclude
122
128
  });
123
129
  log?.info(`Discovered ${files.length} source files via glob`);
124
130
  }
package/dist/exports.d.ts CHANGED
@@ -57,6 +57,20 @@ export interface ExportsDiscoveryResult {
57
57
  export interface ParsedExports {
58
58
  /** All parsed export entries. */
59
59
  entries: Array<ExportEntry>;
60
+ /**
61
+ * Specifiers (exact or wildcard patterns) whose export target resolves
62
+ * nothing — a literal `null`, or a conditions object with no usable
63
+ * target. Node's explicit-exclusion form: `"./internal/*": null` blocks
64
+ * the subpaths a broader wildcard would otherwise expose. Discovery
65
+ * honors these with Node's best-match semantics: a subpath whose
66
+ * most-specific matching key is blocked is not exported, so its source
67
+ * file is not discovered.
68
+ *
69
+ * Interpret via `createBlockedSpecifierChecker` — a naive membership
70
+ * check (`blocked.includes(specifier)`) is wrong for wildcard keys and
71
+ * ignores the positive keys that can out-match a blocked one.
72
+ */
73
+ blocked: Array<string>;
60
74
  /** Whether the package.json had an exports field. */
61
75
  hasExports: boolean;
62
76
  }
@@ -64,12 +78,28 @@ export interface ParsedExports {
64
78
  * Read and parse the exports field from package.json.
65
79
  *
66
80
  * Handles all Node.js export formats: strings, objects with conditions,
67
- * nested conditions, null exclusions, and wildcard patterns.
81
+ * nested conditions, fallback arrays (first usable element), null exclusions
82
+ * (surfaced on `blocked` for best-match blocking during discovery), and
83
+ * wildcard patterns.
68
84
  *
69
85
  * @param projectRoot - absolute path to project root
70
- * @returns parsed `ParsedExports`, or `{entries: [], hasExports: false}` if no exports field
86
+ * @returns parsed `ParsedExports`, or `{entries: [], blocked: [], hasExports: false}` if no exports field
71
87
  */
72
88
  export declare const parsePackageExports: (projectRoot: string) => Promise<ParsedExports>;
89
+ /**
90
+ * Build a predicate deciding whether an export specifier is blocked, per
91
+ * Node's resolution semantics: an exact (starless) key wins outright, else
92
+ * the best-matching wildcard key (`comparePatternKeys`) decides — and when
93
+ * that winner's target is `null`, the subpath is not exported.
94
+ *
95
+ * Blocking is only observable when blocked keys exist, so this returns
96
+ * `null` for the common no-blocked-keys case and callers skip specifier
97
+ * computation entirely.
98
+ *
99
+ * Exported for consumers reading `ParsedExports.blocked` directly — this is
100
+ * the one implementation of the interpretation rule.
101
+ */
102
+ export declare const createBlockedSpecifierChecker: (parsed: ParsedExports) => ((specifier: string) => boolean) | null;
73
103
  /**
74
104
  * Map a dist file path to its source file path.
75
105
  *
@@ -98,6 +128,13 @@ export declare const mapDistToSource: (distPath: string, condition: string, opti
98
128
  * For concrete exports, maps directly to source paths and verifies existence.
99
129
  * For wildcard exports, globs the source directory for matching files.
100
130
  *
131
+ * Null-target keys are honored with Node's resolution semantics: a subpath
132
+ * whose most-specific matching key is `null` is not exported, so its file is
133
+ * not discovered — `"./internal/*": null` beside the usual `"./*.js"`
134
+ * wildcards keeps `src/lib/internal/` out of discovery exactly as it keeps
135
+ * the subpaths unresolvable for consumers (the `src/lib/internal/`
136
+ * convention's exports half).
137
+ *
101
138
  * @param options - discovery configuration
102
139
  * @returns `ExportsDiscoveryResult` with discovered files and any error diagnostics
103
140
  */
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAOjD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;IACnB,2GAA2G;IAC3G,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACpC,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,iCAAiC;IACjC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC5B,qDAAqD;IACrD,UAAU,EAAE,OAAO,CAAC;CACpB;AASD;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC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