chore(DRAFT): use acorn, estree and esrap

#100

Closing issues

Pull request

Closed
M
manuel3108
Oct 13, 2024, 1:29 PM

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 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.

Info

Closed at Dec 23, 2024, 7:21 AM
Assignees None
Reviewers None
Labels None
Milestone None