svelte-ast-print
Print (serialize) Svelte AST nodes into stringified code syntax.
A.k.a. parse()
in reverse.
When using parse()
from "svelte/compiler"
...
please remember about passing modern: true
to options (second argument).
This option is only available starting svelte@5
.
Example:
import { parse } from "svelte/compiler";
parse(code, { modern: true });
// 👆 Don't forget about this!
It determines whether the provided AST node type
is related to Svelte syntax only.
Based on node's type
check from above:
a. it uses either this package's printer to print AST node related to Svelte syntax,
b. otherwise it uses esrap
to print ESTree specification-complaint AST node.
Mateusz "xeho91" Kadlubowski
esrap