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

Created on 5 Jul 2020  路  3Comments  路  Source: vuejs/vetur

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

typescript plan

Most helpful comment

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

All 3 comments

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

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

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

Was this page helpful?
0 / 5 - 0 ratings