vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.85k stars 397 forks source link

Does not work well if dependencies are installed with pnpm #37

Closed Pizzacus closed 3 years ago

Pizzacus commented 3 years ago

Hi, I've tried installing the dependencies on vite-starter-ref-sugar with yarn, and the extension works perfectly. But when the dependencies are installed with pnpm, Volar will think all variables used in the template don't exist.

It happens no matter if setup is used or not. I am using Windows 10.

With setup Without setup
image image

(So either way, it doesn't work)

pnpm is pretty cool, but it installs packages a bit differently.

It uses a lot of symlinks (junctions on Windows actually) to create a global package storage, so that every package only exists on the disk once. It also creates a non-flat node_modules structure, that prevents your code from requiring a package you don't depend on.

And it is probably one of those things that causes a compatibility issue with Volar.

pnpm is normally 100% compatible with Node.js and package bundlers. Even if it creates a different structure from npm, it is completely compliant. Voltar probably makes an assumption at some point about the structure of the node_modules folder that makes it unable to work with it... Or maybe it dislikes symlinks for some reason.

I've found a workaround: Installing @vue/runtime-dom directly, as suggested for Vue 2, makes Volar work as expected. Although I am on Vue 3 so that wouldn't normally be required

johnsoncodehk commented 3 years ago

Thanks for the report! this is because pnpm put '@vue/runtime-dom' module to node_modules/.pnpm/@vue/runtime-dom@x.x.x, so volar import '@vue/runtime-dom' fail. Checking to how to resolve.

johnsoncodehk commented 3 years ago

please try 0.18.12 and let me know if it working or not.

Pizzacus commented 3 years ago

It does seem to work, thank you so much! That was really fast 🚀