Skip to content

v0.6.0

Choose a tag to compare

@github-actions github-actions released this 06 Oct 22:21
· 201 commits to main since this release
Immutable release. Only release title and notes can be modified.
  • breaking feat: parsing returns the span-only AST by default — start/end on every
    node, no loc and no Svelte name_loc — in every package and both CLIs, like acorn's
    locations: false. Pass {locations: true} (or tsv parse --locations) for loc, now
    computed in JS from the offsets and the source and appended last on each object (the native
    CLI places it after end, so a re-serialized tree no longer byte-matches its output);
    --no-locations is gone
  • breaking feat: loc has one definition — the line and UTF-16 column of each object's own
    start/end, counting ECMAScript line terminators in TypeScript (acorn's
    locations: true exactly) and \n alone in Svelte and CSS. Every object with start/end
    gets one (Svelte template nodes, Root, <style>, comments and CSS nodes included), and
    Svelte's loc quirks are not reproduced: a <script>'s Program.loc follows its
    start/end rather than the tag, and a destructured block binding, a block binding's : T
    and a lone CR/LS/PS no longer shift a position. A Svelte source holding a lone CR/LS/PS no
    longer throws
  • breaking feat: tsv_ast.d.ts declares loc and name_loc optional, as estree does; the
    {locations: false} overloads returning any are gone, so every parse returns its typed
    root. parse_*_json takes only sourceType (its string is the span-only wire)
  • breaking feat: create_locator(source, {language}) requires the language and no longer
    takes {ast}; the bare loc_of export is gone (use a locator's); reconstruct_locations
    reads the language off a parse's root — a Root, a StyleSheetFile, or a Program spanning
    the source — and throws on anything else passed without {language}
  • breaking feat: the Loc type is gone for SourceLocation (with Position, the AST types'
    own, at the package root); LocationOptions is ReconstructLocationsOptions, and
    create_locator takes LocatorOptions
  • breaking feat: a parse or format of a source that does not parse throws a SyntaxError
    (typed TsvSyntaxError) with start — the UTF-16 offset, in the AST's coordinates — and
    loc: {line, column}; the message's line:col header follows the same definition, its
    excerpt drops a leading BOM, and a format error is located in the caller's own source, CRLF
    included
  • breaking feat: every argument error is a TypeError, with one message in every package —
    a source that is not a string or not well-formed UTF-16 (the WASM packages read a non-string
    as the empty document outside Node, and a lone surrogate became U+FFFD), a bad options bag, an
    unknown key, a wrong-typed value — and the locations helpers refuse the same way
  • breaking feat: for Rust consumers of the language crates, convert_ast_json_bytes /
    convert_ast_json_string write the span-only wire; the loc wire is
    convert_ast_json_bytes_with_locations, behind a new locations cargo feature, and the
    _no_locations functions are gone
  • feat: a locator's position_at(offset) gives one offset's {line, column}; position_at and
    loc_of throw a RangeError for an offset the source doesn't hold
  • feat: a ./locations subpath export on the parse-capable packages — the line/column helpers
    alone, loading no engine
  • fix: format refuses a Svelte document with a lone CR inside an in-tag // comment, where
    folding the CR to a line feed ended the comment early and turned the rest of its line into
    markup
  • fix: in a Svelte template expression, comments around a JSDoc cast's parens or a grouping
    paren pair attach as Svelte's parser attaches them — a comment Svelte gives the discarded
    paren, the cast's own @type comment included, is no longer attached to the inner expression;
    a {#snippet} parameter's JSDoc cast keeps its ParenthesizedExpression, as Svelte's does
  • fix: a Svelte multi-line block comment's value is dedented by its own line in the document,
    not by the text Svelte's reader handed acorn, so it can differ from Svelte's where a
    <script> prefix, block binding or {#snippet} head shares that line