svelte-ast-print
v1.1.0
Published
Serialize Svelte AST nodes into stringified syntax. A.k.a parse in reverse.
Readme
svelte-ast-print
Print (serialize) Svelte AST nodes into stringified code syntax.
A.k.a. parse() in reverse.
Usage
[!IMPORTANT]
When using
parse()from"svelte/compiler"...
please remember about passingmodern: trueto 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!
How does it work under the hood?
- It determines whether the provided AST node
typeis related to Svelte syntax only. - Based on node's
typecheck from above:
Author
Mateusz "xeho91" Kadlubowski
Acknowledgements
- @manuel3108 for bringing TypeScript support to
esrap
