Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch to estree compatible ast tooling #380

Merged
merged 49 commits into from
Mar 23, 2025

Conversation

manuel3108
Copy link
Member

@manuel3108 manuel3108 commented Dec 29, 2024

Closes #44
Closes #118
Relates #100

This basically duplicates #100 at this point. See #100 for up and downsides of this approach.

I was initially intending to get rid of a lot more dependencies (like the dependencies for handling html) and use svelte-ast-print instead, but this was opening too many issues at the same time. That's why I opted to "only" switch to acorn and esrap here, the rest can be done later.

Relevant PR's / issues

Benefits

  • closer to other tools in the svelte ecosystem
  • Faster bundling (~33% speed improvement locally from 4s to 3s, probably more with chore: use rolldown #371)
  • Smaller bundle (locally 2.6MB vs 3.6MB)
  • more consistent formatting than the strange things we sometimes experienced with recast
  • we are in full control of the printing, as we can control esrap

Downsides

  • Our custom typing for TSEstree as no good public alternative exists, that matches acorns output. We do have @typescript-eslint/types but that was just the one with the smallest pain points. Still exploring other options.

Copy link

changeset-bot bot commented Dec 29, 2024

🦋 Changeset detected

Latest commit: c850286

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sv Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Dec 29, 2024

Open in Stackblitz

npm i https://pkg.pr.new/sveltejs/cli/sv@380
npm i https://pkg.pr.new/sveltejs/cli/svelte-migrate@380

commit: c850286

@manuel3108
Copy link
Member Author

updated PR description to be more accurate.

@manuel3108 manuel3108 added the pkg:add sv add label Feb 2, 2025
@manuel3108
Copy link
Member Author

manuel3108 commented Feb 21, 2025

We are getting close... 🎉 Tests are finally green. Only thing left is to write some code to properly detect quotes and indentation and pass it to esrap correctly. Then we should be good to go.

@manuel3108 manuel3108 changed the title chore: explore parsers and printers chore: switch to estree compatible ast tooling Feb 22, 2025
@svelte-docs-bot
Copy link

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it out and the output looks great!

@manuel3108 manuel3108 merged commit 6c5882c into main Mar 23, 2025
7 checks passed
@manuel3108 manuel3108 deleted the chore/explore-parsers-and-printers branch March 23, 2025 08:00
@github-actions github-actions bot mentioned this pull request Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg:add sv add
Projects
None yet
3 participants