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

Decouple refactorings from babel #275

Closed
nicoespeon opened this issue Apr 23, 2021 · 1 comment
Closed

Decouple refactorings from babel #275

nicoespeon opened this issue Apr 23, 2021 · 1 comment
Assignees
Labels
📦 Refactor Change that doesn't modify existing behavior

Comments

@nicoespeon
Copy link
Owner

When I started the project, I wasn't too familiar with the AST and babel's capabilities. I did the trade-off of relying on babel's interface to implement the refactorings faster.

That works, but it will be an issue in the long run.

We'd better introduce our own abstractions for the AST. We started doing that with the ast module, but it's still very tied to babel.

There would be a few benefits of doing so:

  • make it easier to upgrade babel (we're stuck on an old version because of types: Bump @babel/types from 7.9.0 to 7.13.0 #256)
  • make it possible to switch babel for another parser when convenient (e.g. use TS compiler when relevant, it provides nice features that babel doesn't)
  • build a higher-level API that would simplify refactorings code and make it easier to implement more ambitious refactorings

Because we have so much code tied to it, it won't be an easy task. Hopefully, this is something we can do gradually.

I've been thinking about this for months and I think it's the main refactoring that will benefit the project in the mid-long term.

@nicoespeon nicoespeon added the 📦 Refactor Change that doesn't modify existing behavior label Apr 23, 2021
@nicoespeon nicoespeon self-assigned this Apr 23, 2021
@nicoespeon
Copy link
Owner Author

Less of a priority, I was able to finally upgrade babel: #375

It could be nice to have a higher-level API and be able to switch the parser. But I think we may do that as part of supporting refactoring across files (we may use typescript parser instead).

I also started to build richer functions on top of babel with the ast module. The good news is that it's a proxy, so the rest of the code doesn't depend on babel directly. Although we still inherit a lot of babel interfaces and we could refactor implementation details behind higher-level interfaces…

In any case, it's not a clear win to spend time on this without a concrete feature 👐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Refactor Change that doesn't modify existing behavior
Projects
None yet
Development

No branches or pull requests

1 participant