chore: use parse & print from svelte/compiler

#568

Closing issues

Pull request

Draft
M
manuel3108
May 18, 2025, 9:12 AM

Closes #94 Closes svelte-add/svelte-add#193 Closes svelte-add/svelte-add#507

This is a pretty rough poc to try and make sv work better with .svelte files. Under the hood, this uses svelte-ast-print

Step 1 (support for svelte files):

  • support for svelte specifc html syntax (@attach, self closing component tags, transitions, etc)
  • check and adapt all other usages of parseSvelte
  • make svelte-ast-print support indentation and quote styles (I think some of that already works)
  • fix formatting mistakes in svelte-ast-print (first write up: xeho91/js-ast#128)

Step 2 (reduce deps, different pr probably)

  • we currently use many different libraries for parsing and serializing JS / CSS / HTML. All of that could in theory be handled by svelte/compiler and svelte-ast-print. Check which hoops we need to jump to make that happen. We could potentially drop the following deps:
    • dom-serializer
    • domhandler
    • domutils
    • htmlparser2
    • postcss

Info

Assignees None
Reviewers None
Labels None
Milestone None