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(DRAFT): use acorn, estree and esrap #100

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

manuel3108
Copy link
Member

Closes #94
Closes #44

Benefits

  • closer to other tools in the svelte ecosystem
  • Faster bundling (~33% speed improvement locally from 3s to 2s)
  • Smaller bundle (not tested, but dropping babel should dramatically decrease the bundle size)
  • more consistent formatting
  • we are in full control of the printing, as we own esrap

Downsides

  • Potentially to consistent formatting, as it looks like it's completely ignore the user input (tabs vs spaces, etc), but that's probably fixable in esrap
  • Custom typing for special typescript types (see packages/ast-tooling/ts-estree.ts) and add typescript support Rich-Harris/esrap#13 for reasoning and considered alternatives.

Depends on Rich-Harris/esrap#13. Currently published as esrap-typescript-temp for ease of use for testing. Otherwise, this would require using pnpm link locally with the branch mentioned before.

If we want to proceed with this (which i think we should), this needs to be done

  • publish packages/ast-tooling/ts-estree.ts seperately so that it can also be used inside esrap. Later they should probably live inside acorn-typescript once we fork it
  • make esrap understand what a TSModuleDeclaration is and how to print it
  • update types inside esrap according to the types above. This will probably also require way more types in this new package
  • merge the pr inside esrap and publish it
  • fix todos
  • Testing. I have done a few tests here and there and generally the formatting is way more consistent and matches what i would expect.

Copy link

changeset-bot bot commented Oct 13, 2024

⚠️ No Changeset found

Latest commit: 53921b6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

pkg-pr-new bot commented Oct 13, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/sveltejs/cli/sv@100

commit: 53921b6

@benmccann
Copy link
Member

publish packages/ast-tooling/ts-estree.ts seperately so that it can also be used inside esrap. Later they should probably live inside acorn-typescript once we fork it

I think it'd be preferrable to just duplicate it in the short-term than to add a dependency on ast-tooling from esrap. Hopefully that can be short-lived and we can just add it to the acorn-typescript fork like you suggest

update types inside esrap according to the types above. This will probably also require way more types in this new package

That would be nice, but I wouldn't necessarily block on it. It will be a huge cleanup just to get this done and get off of recast, so if there are some things left for followups that would be fine

@manuel3108
Copy link
Member Author

I think it'd be preferrable to just duplicate it in the short-term than to add a dependency on ast-tooling from esrap. Hopefully that can be short-lived and we can just add it to the acorn-typescript fork like you suggest

I was thinking about a custom package just for those types, but copying over should also work, if we want proceed with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use { parse } from 'svelte/compiler' File created with mix of single and double quotes
2 participants