sveld 0.35.2 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/lib/browser.d.ts +660 -39
- package/lib/browser.js +172 -172
- package/lib/chunk-0fqdg2xa.js +20 -0
- package/lib/chunk-2vwf7nck.js +1 -0
- package/lib/chunk-8myyzjb1.js +4 -0
- package/lib/{chunk-v4q9vw0y.js → chunk-as5hgj7e.js} +57 -57
- package/lib/{chunk-zva3xjwa.js → chunk-denfbw92.js} +1 -1
- package/lib/chunk-h1r040pg.js +6 -0
- package/lib/chunk-m538qnhp.js +230 -0
- package/lib/chunk-r4rrncmd.js +1 -0
- package/lib/{chunk-1p4ka68s.js → chunk-t9d5k3p7.js} +1 -1
- package/lib/{chunk-8xw75w8t.js → chunk-tmj7vnjr.js} +2 -2
- package/lib/chunk-xryt7ad2.js +3 -0
- package/lib/cli-entry.js +1 -1
- package/lib/index.d.ts +767 -10
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/lib/ComponentParser.d.ts +0 -560
- package/lib/ast-guards.d.ts +0 -16
- package/lib/brands.d.ts +0 -11
- package/lib/bundle.d.ts +0 -174
- package/lib/check.d.ts +0 -43
- package/lib/chunk-72hx9e9w.js +0 -20
- package/lib/chunk-7qz0hzgw.js +0 -217
- package/lib/chunk-cxrw7gzr.js +0 -2
- package/lib/chunk-jdnsv86e.js +0 -1
- package/lib/chunk-pmj8c3yv.js +0 -6
- package/lib/chunk-s9mzxa4y.js +0 -1
- package/lib/chunk-xkrgedm4.js +0 -4
- package/lib/cli-entry.d.ts +0 -12
- package/lib/cli.d.ts +0 -28
- package/lib/create-exports.d.ts +0 -32
- package/lib/dependency-graph.d.ts +0 -20
- package/lib/diagnostics.d.ts +0 -34
- package/lib/element-tag-map.d.ts +0 -146
- package/lib/example-check.d.ts +0 -24
- package/lib/get-svelte-entry.d.ts +0 -3
- package/lib/load-config.d.ts +0 -62
- package/lib/parse-cache.d.ts +0 -28
- package/lib/parse-entry-exports.d.ts +0 -30
- package/lib/parse-exports.d.ts +0 -25
- package/lib/parsed-component-metadata.d.ts +0 -13
- package/lib/parser/bindings.d.ts +0 -4
- package/lib/parser/context.d.ts +0 -72
- package/lib/parser/contexts.d.ts +0 -19
- package/lib/parser/diagnostics.d.ts +0 -8
- package/lib/parser/events.d.ts +0 -21
- package/lib/parser/generics.d.ts +0 -24
- package/lib/parser/jsdoc.d.ts +0 -55
- package/lib/parser/prop-shared.d.ts +0 -84
- package/lib/parser/props.d.ts +0 -71
- package/lib/parser/rest-props.d.ts +0 -4
- package/lib/parser/runes-detection.d.ts +0 -13
- package/lib/parser/runes-props.d.ts +0 -18
- package/lib/parser/scopes.d.ts +0 -56
- package/lib/parser/slots.d.ts +0 -24
- package/lib/parser/source-position.d.ts +0 -26
- package/lib/parser/type-resolution.d.ts +0 -17
- package/lib/parser/typescript-casts.d.ts +0 -1
- package/lib/parser/utils.d.ts +0 -1
- package/lib/parser/variable-jsdoc.d.ts +0 -12
- package/lib/parser-stack.d.ts +0 -20
- package/lib/path.d.ts +0 -2
- package/lib/plugin.d.ts +0 -85
- package/lib/resolve-alias.d.ts +0 -30
- package/lib/resolve-types.d.ts +0 -52
- package/lib/sveld.d.ts +0 -29
- package/lib/svelte-parse.d.ts +0 -4
- package/lib/svelte-version.d.ts +0 -1
- package/lib/validate.d.ts +0 -13
- package/lib/watch.d.ts +0 -34
- package/lib/writer/MarkdownWriterBase.d.ts +0 -26
- package/lib/writer/Writer.d.ts +0 -31
- package/lib/writer/WriterMarkdown.d.ts +0 -31
- package/lib/writer/built-in-writers.d.ts +0 -1
- package/lib/writer/document-model.d.ts +0 -34
- package/lib/writer/format-generated-ts.d.ts +0 -8
- package/lib/writer/markdown-format-utils.d.ts +0 -20
- package/lib/writer/markdown-render-utils.d.ts +0 -10
- package/lib/writer/registry.d.ts +0 -17
- package/lib/writer/writer-custom-elements-core.d.ts +0 -86
- package/lib/writer/writer-custom-elements.d.ts +0 -15
- package/lib/writer/writer-json.d.ts +0 -27
- package/lib/writer/writer-markdown-core.d.ts +0 -32
- package/lib/writer/writer-markdown.d.ts +0 -23
- package/lib/writer/writer-ts-definitions-core.d.ts +0 -30
- package/lib/writer/writer-ts-definitions.d.ts +0 -43
package/README.md
CHANGED
|
@@ -130,6 +130,7 @@ export default class Button extends SvelteComponentTyped<
|
|
|
130
130
|
- [Installation](#installation)
|
|
131
131
|
- [Vite](#vite)
|
|
132
132
|
- [CLI](#cli)
|
|
133
|
+
- [Exit codes](#exit-codes)
|
|
133
134
|
- [CI: API-drift checks (`--check`)](#ci-api-drift-checks---check)
|
|
134
135
|
- [Node.js](#nodejs)
|
|
135
136
|
- [Browser](#browser)
|
|
@@ -375,7 +376,7 @@ By default, nothing is printed. Opt in when you are working on types or want CI
|
|
|
375
376
|
await sveld({ json: true, reportDiagnostics: true });
|
|
376
377
|
```
|
|
377
378
|
|
|
378
|
-
Use `strict: true` (or `--strict`) to exit with code `
|
|
379
|
+
Use `strict: true` (or `--strict`) to exit with code `4` when diagnostics exist. `strict` implies `reportDiagnostics`, so CI always shows why the run failed.
|
|
379
380
|
|
|
380
381
|
```ts
|
|
381
382
|
await sveld({ json: true, strict: true });
|
|
@@ -471,13 +472,35 @@ npx sveld --json --markdown
|
|
|
471
472
|
|
|
472
473
|
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.
|
|
473
474
|
|
|
474
|
-
Flags are kebab-case: `--entry`, `--glob`, `--types`, `--json`, `--markdown`, `--fail-fast`, `--cache`, `--resolve-types`, `--check-examples`, `--report-diagnostics`, `--strict`, `--check`, `--types-format`. The camelCase spellings `--resolveTypes` and `--checkExamples` still work as deprecated aliases for compatibility with existing scripts. An unrecognized flag (e.g. `--markdwon`) prints `Unknown flag: --markdwon` to `stderr`, exits `1`, and skips generation; sveld takes no positional arguments, so any non-flag argument errors the same way.
|
|
475
|
+
Flags are kebab-case: `--entry`, `--glob`, `--types`, `--json`, `--markdown`, `--fail-fast`, `--dry-run`, `--cache`, `--resolve-types`, `--check-examples`, `--report-diagnostics`, `--strict`, `--check`, `--types-format`, `--quiet`, `--stdout`, `--format`. The camelCase spellings `--resolveTypes` and `--checkExamples` still work as deprecated aliases for compatibility with existing scripts. `--entry`, `--cache`, `--check`, and `--types-format` 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 `--entry` and `--types-format` report a usage error naming the flag. Boolean flags (`--json`, `--glob`, `--strict`, 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.
|
|
476
|
+
|
|
477
|
+
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.
|
|
478
|
+
|
|
479
|
+
Pass `--dry-run` to resolve the entry, load config, and parse components through the real pipeline (so parse errors, diagnostics, `--strict`, and `--check` all behave as in a real run), then print `would write "<path>"` to `stdout` for each output file instead of writing it, e.g. `sveld --json --markdown --dry-run`. Nothing is written, including the parse cache. `--check` never writes regardless of `--dry-run`, since it only diffs against the committed snapshot.
|
|
480
|
+
|
|
481
|
+
Pass `--stdout` alongside exactly one of `--json`, `--markdown`, or `--custom-elements` to print that single document to `stdout` instead of writing it to disk, e.g. `sveld --json --stdout | jq '.components[].moduleName'`. Zero or more than one of those three flags, `--types`, or `--check` combined with `--stdout` is a usage error that prints to `stderr` and exits `1` without generating anything; the default `.d.ts` generation is skipped in `--stdout` mode since type definitions span multiple files.
|
|
482
|
+
|
|
483
|
+
`--stdout=ndjson` (only valid with `--json`) prints one minified JSON object per exported component per line instead of the single combined document, in the same order as the combined document's `components` array, e.g. `sveld --json --stdout=ndjson | jq -c 'select(.props | length > 0)'`. Lines are only written after the run completes (component records are only final after cross-component resolution), so this is a line-oriented serialization format, not incremental streaming. Bare `--stdout` (or `--stdout=json`) keeps the single-document behavior; any other value is a usage error.
|
|
484
|
+
|
|
485
|
+
`--format=json` switches the `--check` report and the `--report-diagnostics` / `--strict` diagnostics summary from prose to JSON, so scripts and agents don't have to regex the text output, e.g. `sveld --json --check --format=json | jq '.bump'`. Channels are unchanged: the check report prints to `stdout` and the diagnostics summary to `stderr`, same as the text format. The default remains `--format=text`; an unrecognized value (e.g. `--format=yaml`) is a usage error that prints to `stderr` and exits `1` without generating anything.
|
|
475
486
|
|
|
476
487
|
Run `npx sveld --help` for the full flag list with descriptions, or `npx sveld --version` to print the installed version.
|
|
477
488
|
|
|
489
|
+
### Exit codes
|
|
490
|
+
|
|
491
|
+
| Code | Meaning |
|
|
492
|
+
|------|---------|
|
|
493
|
+
| `0` | Success |
|
|
494
|
+
| `1` | Usage or configuration error (unknown flag, bad flag value, unresolvable entry) |
|
|
495
|
+
| `2` | Generation failure (a component failed to parse under `--fail-fast`, or an unrecoverable pipeline error) |
|
|
496
|
+
| `3` | Breaking API change detected by `--check` |
|
|
497
|
+
| `4` | Diagnostics present under `--strict` |
|
|
498
|
+
|
|
499
|
+
Every failure is still reported to its usual channel even when more than one applies in a single run (e.g. a breaking change under `--check` alongside diagnostics under `--strict`); the process exits with the lowest applicable code. All failure codes are nonzero, so existing `if sveld; then ...` and `set -e` scripts that only check for success keep working unmodified.
|
|
500
|
+
|
|
478
501
|
### CI: API-drift checks (`--check`)
|
|
479
502
|
|
|
480
|
-
`--check` diffs the parsed component API against a committed `COMPONENT_API.json` snapshot, assigns a semver bump to each change, and exits `
|
|
503
|
+
`--check` diffs the parsed component API against a committed `COMPONENT_API.json` snapshot, assigns a semver bump to each change, and exits `3` when it finds a breaking change.
|
|
481
504
|
|
|
482
505
|
1. Generate and commit the snapshot once: `npx sveld --json`, then commit `COMPONENT_API.json`.
|
|
483
506
|
2. Add `npx sveld --check` to CI:
|
|
@@ -501,7 +524,9 @@ Removed props, events, or slots, and props that become required, are breaking (`
|
|
|
501
524
|
|
|
502
525
|
Use `--check=<path>` to diff against a snapshot at a custom location (defaults to `jsonOptions.outFile`, or `COMPONENT_API.json`).
|
|
503
526
|
|
|
504
|
-
The CLI exits non-zero on any fatal error (an unreadable entry, a config file that throws, etc.), not just on `--strict`/`--check` findings, so it's safe to use either flag as a CI gate.
|
|
527
|
+
The CLI exits non-zero on any fatal error (an unreadable entry, a config file that throws, etc.), not just on `--strict`/`--check` findings, so it's safe to use either flag as a CI gate. See [Exit codes](#exit-codes) for how these are differentiated.
|
|
528
|
+
|
|
529
|
+
Pass `--format=json` for a machine-readable report on `stdout` instead of the prose above, e.g. `sveld --check --format=json | jq '.bump'` or `sveld --check --format=json | jq '.changes[] | select(.bump == "major")'`.
|
|
505
530
|
|
|
506
531
|
### Node.js
|
|
507
532
|
|
|
@@ -697,8 +722,10 @@ The `svelte` condition lets bundlers that understand it (Vite, Rollup, webpack v
|
|
|
697
722
|
- **`cache`** (boolean | string, optional, default: `true`): Write parsed component output to disk and skip re-parsing unchanged files on later runs. On by default, writing to `node_modules/.cache/sveld/parse-cache.json`; a string sets a custom path; pass `false` to disable. Also available as `--cache` / `--cache=<path>` / `--cache=false`. See [Persistent parse cache](#persistent-parse-cache-cache).
|
|
698
723
|
- **`checkExamples`** (boolean, optional, default: `false`): Run plain TS/JS `@example` blocks through the TypeScript program. Broken ones get an `example-compile-error` diagnostic. Also available as `--check-examples` (`--checkExamples` remains as a deprecated alias). See [Compile-checked `@example` blocks](#compile-checked-example-blocks-checkexamples).
|
|
699
724
|
- **`reportDiagnostics`** (boolean, optional, default: `false`): Print unresolved-type diagnostics to stderr (CLI) or `console.warn` (programmatic API). Also available as `--report-diagnostics`. See [Type inference diagnostics](#type-inference-diagnostics).
|
|
700
|
-
- **`strict`** (boolean, optional, default: `false`): Exit with code `
|
|
701
|
-
- **`check`** (boolean | string, optional, default: `false`): Diff the parsed component API against a committed snapshot and assign a semver bump to each change. `true` uses the `json` writer's `outFile` (or `COMPONENT_API.json`); a string sets a custom snapshot path. Also available as `--check` / `--check=<path>`. On the CLI this exits `
|
|
725
|
+
- **`strict`** (boolean, optional, default: `false`): Exit with code `4` when diagnostics exist. Implies `reportDiagnostics`. Also available as `--strict`. See [Type inference diagnostics](#type-inference-diagnostics).
|
|
726
|
+
- **`check`** (boolean | string, optional, default: `false`): Diff the parsed component API against a committed snapshot and assign a semver bump to each change. `true` uses the `json` writer's `outFile` (or `COMPONENT_API.json`); a string sets a custom snapshot path. Also available as `--check` / `--check=<path>`. On the CLI this exits `3` on a breaking change; from `sveld()` it's returned on `SveldResult.check` for you to act on. See [CI: API-drift checks (`--check`)](#ci-api-drift-checks---check).
|
|
727
|
+
- **`quiet`** (boolean, optional, default: `false`): Suppress writer progress logs (`created "..."` / `unchanged "..."`), which print to `stderr` by default. Does not suppress error messages, the diagnostics summary, or the `--check` report. Also available as `--quiet`.
|
|
728
|
+
- **`dryRun`** (boolean, optional, default: `false`): Resolve the entry, load config, and parse components through the real pipeline, then print `would write "<path>"` to `stdout` for each output file instead of writing it, including the parse cache. Diagnostics, `strict`, and `check` behave as in a real run. CLI-only via `--dry-run`; the Vite plugin does not expose this option.
|
|
702
729
|
|
|
703
730
|
By default, only TypeScript definitions are generated.
|
|
704
731
|
|