Skip to content

v0.36.0

Choose a tag to compare

@metonym metonym released this 14 Jul 18:33
· 161 commits to main since this release
v0.36.0
974d42b

Features

  • add --stdout to emit one of --json, --markdown, or --custom-elements to stdout (f8fc9f9, #384)
  • support --stdout=ndjson for per-component JSON lines (adc19eb, #385)
  • add --format=json for check and diagnostics output (d669ea2, #386)
  • differentiate CLI exit codes by failure kind (c910f4f, #387)
  • accept space-separated flag values and suggest corrections for unknown flags (2ac26eb, #388)
  • add --dry-run to preview outputs without writing (55e92c8, #389)
  • route progress logs to stderr and add --quiet (00c7dc3)
  • roll public types into single entry .d.ts files (9d0751a)
  • parse each component once instead of twice (d2ed0b4, #392)
  • stop re-parsing components to strip the style block (a6723a0, #393)

CLI piping and scripting

0.36.0 is a CLI-focused minor that makes sveld safer to pipe, script, and wire into CI.

Writers used to print progress lines like created "COMPONENT_API.json" to stdout, which mixed logs with data. Progress now goes to stderr. --quiet (and the quiet runtime option) suppresses those lines entirely; errors, the diagnostics summary, and the --check report still print.

--stdout with exactly one of --json, --markdown, or --custom-elements prints that document to stdout and writes nothing to disk. Default .d.ts generation is skipped in stdout mode. --stdout=ndjson (with --json) emits one JSON object per exported component per line after the run completes, so stream tools can consume large libraries without parsing a single large document.

--format=json emits the --check report as structured JSON on stdout and the diagnostics summary as structured JSON on stderr. The default remains text.

Exit codes

The CLI previously exited 1 for every failure. Exit codes now distinguish failure kind:

Code Meaning
0 success
1 usage or configuration error
2 generation failure
3 breaking API change detected by --check
4 diagnostics present under --strict

When more than one applies, the lowest code wins. All failures remain nonzero, so existing if [ $? -ne 0 ] checks keep working. Scripts that branched on exit code 1 for --strict should switch to 4.

Dry-run and flag UX

--dry-run resolves the entry, loads config, and parses components through the real pipeline, then prints one would write line per output file without writing anything (including the parse cache). Diagnostics, --strict, and --check behave as in a real run.

Value-taking flags (--entry, --cache, --check, --types-format) accept either --flag=value or --flag value. Unknown flags suggest the closest known flag by edit distance.

Performance

Each component used to go through svelte's parser more than once: a modern AST pass for runes metadata, a legacy AST pass for the main walk, and (on the CLI path) another full parse just to learn where the <style> block ends so it could be stripped before a JSDoc scan.

parseModernAndLegacy() now calls parseFragment once and derives both AST views from that result. The legacy view still needs svelte's in-place convert(), so it runs on a cheap hand-rolled clone of the modern tree — structuredClone cost about as much as a fresh parse and erased the win.

Style stripping no longer re-parses either. The css node is already on the shared AST, so bounds come from there. The JSDoc scan that must not see comments inside <style> runs against a same-length masked copy of the source; ctx.source stays intact so other offset math is unaffected. That protection now applies whenever parseSvelteComponent runs, not only via the CLI bundle path.

Published types

The published package no longer mirrors every src module into lib/ as separate declaration files. Public types are rolled into single entry .d.ts files for sveld and sveld/browser, matching package exports. This reduces the size of the distributed package.