vuejs / vetur

Vue tooling for VS Code.
https://vuejs.github.io/vetur/
MIT License
5.75k stars 594 forks source link

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

Open octref opened 4 years ago

octref commented 4 years ago

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:


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:

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 commented 4 years ago

Linking to https://github.com/microsoft/TypeScript/issues/38736 which I think is request for a tsc only version of the pattern

vegerot commented 4 years ago

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

octref commented 4 years ago

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