sveld 0.37.8 → 0.37.9

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
@@ -366,7 +366,7 @@ A prop with no type annotation, no `@type` JSDoc, and no initializer has nothing
366
366
  With `reportDiagnostics` or `strict`, the grouped summary looks like this:
367
367
 
368
368
  ```
369
- sveld: 5 unresolved types found.
369
+ sveld: 5 diagnostics (1 error, 4 warnings).
370
370
 
371
371
  Props without inferred types (1):
372
372
  ./icons/Add.svelte
@@ -382,8 +382,8 @@ Context values typed as `any` (1):
382
382
  - @event "close" has no matching dispatch or callback prop. (./Modal.svelte:4:5) [sveld/event-no-source]
383
383
 
384
384
  Component syntax sveld skipped (1):
385
- ./Tabs.svelte
386
- - {@render tabs(getTabProps())} argument is not a plain object literal; the render call was not mapped to slot metadata. (./Tabs.svelte:6:4) [sveld/syntax-skipped]
385
+ ./List.svelte
386
+ - Both the "generics" script attribute and @generics/@template JSDoc tags declare component generics; the script attribute takes precedence and the JSDoc declaration was ignored. (./List.svelte:1:1) [sveld/syntax-skipped]
387
387
  ```
388
388
 
389
389
  When `checkExamples` is also enabled, `@example` failures appear as additional groups: TS/JS failures under `example-compile-error`, `svelte`/`html` failures under `example-syntax-error`.
@@ -468,7 +468,7 @@ await sveld({ json: true, strict: "errors" });
468
468
 
469
469
  #### Ignoring diagnostics
470
470
 
471
- Two ways to suppress a diagnostic without disabling `strict` for the whole run. Either way, the diagnostic still appears in `SveldResult.diagnostics` (with `ignored: true`) and is still counted in the text summary (`sveld: 2 unresolved types found (1 ignored).`), but never fails `--strict` / `--strict=errors`.
471
+ Two ways to suppress a diagnostic without disabling `strict` for the whole run. Either way, the diagnostic still appears in `SveldResult.diagnostics` (with `ignored: true`) and is still counted in the text summary (`sveld: 2 diagnostics (0 errors, 2 warnings) (1 ignored).`), but never fails `--strict` / `--strict=errors`.
472
472
 
473
473
  **Config matchers** (`diagnostics.ignore`, an array of `{ code?, component?, name? }`): every field you set on a matcher must match for it to apply; an omitted field matches anything. `component` is a glob (`*` within a path segment, `**` across segments):
474
474
 
@@ -601,7 +601,7 @@ npx sveld --json --markdown
601
601
 
602
602
  If no entry point can be resolved (no `package.json#svelte` field and no `--entry`), the CLI exits `1` and prints the reason to `stderr`. If `src/index.js` happens to exist relative to your working directory, sveld falls back to it and prints a one-line note asking you to set `package.json#svelte` (or `--entry`) instead of relying on the fallback.
603
603
 
604
- Flags are kebab-case: `--entry`, `--glob`, `--types`, `--json`, `--markdown`, `--custom-elements`, `--llms`, `--fail-fast`, `--dry-run`, `--cache`, `--resolve-types`, `--check-examples`, `--report-diagnostics`, `--strict`, `--check`, `--check-level`, `--types-format`, `--types-export`, `--types-comments`, `--types-inline`, `--types-index-types`, `--types-props-declaration`, `--quiet`, `--stdout`, `--format`. The camelCase spellings `--resolveTypes` and `--checkExamples` still work as deprecated aliases for compatibility with existing scripts. `--entry`, `--cache`, `--check`, `--types-format`, `--types-export`, `--types-comments`, `--types-inline`, and `--types-props-declaration` take their value either as `--flag=value` or as a separate `--flag value` argument (`sveld --entry src/index.js` and `sveld --entry=src/index.js` are equivalent); if the next argument starts with `--` it's not consumed as a value, so `--cache` and `--check` fall back to their default location and the rest of that list report a usage error naming the flag. Boolean flags (`--json`, `--glob`, `--strict`, `--types-index-types`, and the like) never consume a following argument. An unrecognized flag (e.g. `--markdwon`) prints `Unknown flag: --markdwon` to `stderr`, exits `1`, and skips generation; when a close match exists it appends a suggestion, e.g. `Unknown flag: --markdwon Did you mean --markdown?`. sveld takes no positional arguments, so any non-flag argument errors the same way.
604
+ Flags are kebab-case: `--entry`, `--glob`, `--types`, `--json`, `--markdown`, `--custom-elements`, `--llms`, `--fail-fast`, `--dry-run`, `--cache`, `--resolve-types`, `--check-examples`, `--report-diagnostics`, `--strict`, `--check`, `--check-level`, `--types-format`, `--types-export`, `--types-comments`, `--types-inline`, `--types-index-types`, `--types-props-declaration`, `--quiet`, `--stdout`, `--format`. The camelCase spellings `--resolveTypes` and `--checkExamples` still work as deprecated aliases for compatibility with existing scripts. `--entry`, `--cache`, `--check`, `--types-format`, `--types-export`, `--types-comments`, `--types-inline`, and `--types-props-declaration` take their value either as `--flag=value` or as a separate `--flag value` argument (`sveld --entry src/index.js` and `sveld --entry=src/index.js` are equivalent); if the next argument starts with `--` it's not consumed as a value, so `--cache` and `--check` fall back to their default location and the rest of that list report a usage error naming the flag. Boolean flags (`--json`, `--glob`, `--strict`, `--types-index-types`, and the like) never consume a following argument. An unrecognized flag (e.g. `--markdwon`) prints `sveld: unknown flag "--markdwon".` to `stderr`, exits `1`, and skips generation; when a close match exists it appends a suggestion, e.g. `Did you mean "--markdown"?`. sveld takes no positional arguments, so any non-flag argument errors the same way.
605
605
 
606
606
  Writer progress lines (`created "..."` / `unchanged "..."`) print to `stderr`, keeping `stdout` reserved for machine-readable data. Pass `--quiet` (or `quiet: true` in `sveld.config.*`) to suppress them; it does not suppress error messages, the diagnostics summary (`--report-diagnostics` / `--strict`), or the `--check` report.
607
607
 
@@ -965,7 +965,7 @@ The `svelte` condition lets bundlers that understand it (Vite, Rollup, webpack v
965
965
  - **`linkBase`** (string, optional, default: `""`): Prefixed to each component's link in `llms.txt`.
966
966
  - **`title`** (string, optional, default: the `"name"` field from `package.json`): The `# <title>` heading both files start with.
967
967
  - **`summary`** (string, optional, default: the `"description"` field from `package.json`): The `> <summary>` blockquote under the title.
968
- - **`config`** (boolean | string, optional, default: `false`): Load `sveld.config.{js,mjs,ts}` and merge it with these options; these options win when a key is set in both. `true` resolves the config from the Vite project root (or `process.cwd()` outside Vite); a string is an explicit path to the config file. See [Config File](#config-file).
968
+ - **`config`** (boolean | string, optional, default: `false`): Load `sveld.config.{js,mjs,ts}` and merge it with these options; these options win when a key is set in both. `true` resolves the config from the Vite project root (or `process.cwd()` outside Vite); a string is an explicit path to the config file. The plugin warns about keys only the CLI and `sveld()` act on (`reportDiagnostics`, `strict`, `check`, `checkLevel`, `stdout`, `format`, `dryRun`). See [Config File](#config-file).
969
969
  - **`watch`** (boolean, optional, default: `false`): Regenerate output incrementally when relevant source changes during `vite dev` / `vite build --watch`. A reparse is triggered by: editing a component; editing the entry barrel itself, which adds/removes the corresponding component; or editing a non-`.svelte` file a component depends on via [`@extendProps`](#extendprops) / `@extends` or a typedef `import("./x")` reference. Only the affected components are re-parsed, rather than rebuilding every component. Overlapping regenerations are queued, never run concurrently. Without this option, the plugin only runs during `vite build`.
970
970
  - **`failFast`** (boolean, optional, default: `false`): Abort the entire run when a single component fails to parse. By default, parse failures are collected as diagnostics (and reported to `stderr`) so the remaining components still emit their output. Also available as the `--fail-fast` CLI flag.
971
971
  - **`resolveTypes`** (boolean, optional, default: `false`): Load the TypeScript program to expand opaque imported whole-object `$props()` types into JSON. Also available as `--resolve-types` (`--resolveTypes` remains as a deprecated alias). See [Opt-in semantic resolution](#opt-in-semantic-resolution-resolvetypes).
@@ -2025,6 +2025,21 @@ For `lang="ts"` components, prefer native TypeScript annotations when you alread
2025
2025
 
2026
2026
  For runes components with multiple destructured props, put JSDoc on the property you want to document. A declaration-level block is a fallback when the destructure exposes a single public prop.
2027
2027
 
2028
+ A declaration-level `@type` naming an object `@typedef` (or an inline `{ ... }` type) types the whole `$props()` object instead, the form Svelte's docs recommend for JavaScript components. Each prop takes its type, optionality, and description from the matching member:
2029
+
2030
+ ```svelte
2031
+ <script>
2032
+ /**
2033
+ * @typedef {object} Props
2034
+ * @property {string} title Card title
2035
+ * @property {boolean} [elevated=false] Raise the card
2036
+ */
2037
+
2038
+ /** @type {Props} */
2039
+ let { title, elevated = false } = $props();
2040
+ </script>
2041
+ ```
2042
+
2028
2043
  <details>
2029
2044
  <summary>Svelte 3/4 (legacy) syntax</summary>
2030
2045
 
package/cli.js CHANGED
@@ -1,5 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // biome-ignore lint/performance/noNamespaceImport: a named import of enableCompileCache fails to link on Node < 22.1.
4
+ import * as nodeModule from "node:module";
5
+
6
+ // Caches V8's compiled bytecode for sveld's own modules across runs (Node
7
+ // 22.1+; a no-op on older Node and Bun), so startup skips recompiling them.
8
+ nodeModule.enableCompileCache?.();
9
+
3
10
  import("./lib/cli-entry.js")
4
11
  .then(({ cli }) => cli(process))
5
12
  .catch((error) => {
package/lib/browser.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { Node, Property } from "estree";
2
2
 
3
+ import type { FunctionDeclaration, VariableDeclaration } from "estree";
4
+
3
5
  declare const brand: unique symbol;
4
6
 
5
7
  type Brand<TBase extends string, TBrand extends string> = TBase & {