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

Explore TS Plugin support in Vetur by integrating znck/developer-experience's refactor support #2016

Open
2 tasks
octref opened this issue Jul 5, 2020 · 3 comments

Comments

@octref
Copy link
Member

octref commented Jul 5, 2020

Chatted with @znck, here's a summary:

znck/vue-developer-experience is a TS Plugin that uses a virtual file system to support Vue files. Currently it only supports Vue 3 but not Vue 2, because it creates virtual files without modifying AST (so you cannot wrap export default {} to export default Vue.extend({}). It adds most TS language features to Vue files.

Vetur currently has limitations that can only be solved by a TS Plugin. For example, rename/refactor in JS/TS files should generate changes across a project's JS/TS/Vue files, but with Vetur's current approach it won't support Vue files, so renaming might create compiler errors.

A lot of Vetur's static analysis code can live either in language server or in a TS Plugin, but both have their limitations:

  • Language Server: cannot interfere with TS language features
  • TS Plugin: has no access to VS Code API

Me and @znck will try a MVP to validate if it's possible to integrate our work:

Add a TS Plugin to Vetur, drop Vetur's refactor support (but keep others such as auto-completion), and delegate that to the TS Plugin

This work should make rename and other refactor work across JS/TS/Vue files.
This will exist as a separate branch/build, as it only supports Vue 3. Once we validate the idea we can try integrating the work into Vetur.

Todo:

  • Setup basic infrastrcuture for adding a TS Plugin
  • Test if we can have bi-directional communication between a TS Plugin and a LSP server

Once we are done with above, we can try if it's possible to do AST transform in a TS Plugin, so we could support Vue 2. Considering that we have done that in Vetur, it shouldn't be hard.

/cc @znck @ktsn

Might be of your interest as well @orta @DanielRosenwasser

@orta
Copy link

orta commented Jul 5, 2020

Linking to microsoft/TypeScript#38736 which I think is request for a tsc only version of the pattern

@vegerot
Copy link

vegerot commented Sep 17, 2020

This looks like a very promising project. @octref what's the word? 🙂

@octref
Copy link
Member Author

octref commented Sep 21, 2020

No update yet, this will take a lot of time and effort. If you want to see more development, you can consider sponsoring my work: https://github.com/sponsors/octref

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

No branches or pull requests

3 participants