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

[Bug] PnPify in Visual Studio Code does not support "Go to Definition" #806

Closed
1 task
dallonf opened this issue Jan 27, 2020 · 6 comments
Closed
1 task
Labels
bug Something isn't working external bug This issue highlights a bug in another project

Comments

@dallonf
Copy link

dallonf commented Jan 27, 2020

  • I'd be willing to implement a fix

Describe the bug

When using the PnPify workflow in Visual Studio Code, attempting to "Go to Definition" of a dependency results in VS Code attempting, and failing, to open a source file from inside a zipped package in the cache:

Unable to open 'index.d.ts': Unable to read file (Error: File not found (c:\Users\dallo\devroot\tmp\my-app\.yarn\cache\@types-react-npm-16.9.19-21809ae185-1.zip\node_modules\@types\react\index.d.ts)).

To Reproduce

(This isn't exactly minimal since I don't think Create React App is part of the issue, but it's at least very simple to reproduce, and I don't have time to figure out how to create a project without a template right now. Would appreciate anyone with more context helping break it down a little more)

  1. Create an app with Create React App as described in the CRA docs:
npx create-react-app my-app --template typescript
  1. Follow the instructions to enable PnPify in Visual Studio Code: https://yarnpkg.com/advanced/editor-sdks#vscode
  2. In App.tsx, try to "Go to Definition" on the React package.

Screenshots

image

Environment if relevant (please complete the following information):

  • OS: Windows 10, build 18362.592
  • Node v13.7.0
  • Yarn v2.0.0-rc.27

Additional context

Looks like the root of the issue is that it's trying to go inside a zip file.

@dallonf dallonf added the bug Something isn't working label Jan 27, 2020
@arcanis arcanis added the external bug This issue highlights a bug in another project label Jan 27, 2020
@arcanis
Copy link
Member

arcanis commented Jan 27, 2020

Yes, this is a known issue - there is an open ticket on the VSCode tracker to fix it, we can't do it on our side (I've experimented with it already, we even have a zip extension in this very repository, but without the right hooks it's fairly useless).

My best advice is to upvote the VSCode issue to help their team prioritize it 🙂

@skeate
Copy link

skeate commented Jan 28, 2020

This is also an issue with $$virtual, but a bit worse because $$virtual doesn't actually exist, so even if my editor could just open files inside a zip, it would still fail to find it.

I'm not sure why some things are resolving to $$virtual and others aren't; the closest thing to docs I found is this line:

Due to a particularity in how Yarn installs packages which list peer dependencies, some packages will be mapped to multiple virtual directories that don't actually exist on the filesystem. This settings tells Yarn where to put them. Note that the folder name must be $$virtual.

from here

@arcanis
Copy link
Member

arcanis commented Jan 28, 2020

@skeate explanation about virtual packages is here: https://yarnpkg.com/advanced/lexicon#virtual-package

@skeate
Copy link

skeate commented Jan 28, 2020

Thanks for that link, though it's a little hard to understand without an example given. But I don't want to derail this issue with a tangent.

Do you agree that it's an issue, or should editors be able to access $$virtual somehow?

Also, aside for anyone else finding this thread who wants a fix now: yarn unplug <pkg>

@dallonf
Copy link
Author

dallonf commented Jan 28, 2020

My mistake, I missed the "caveat" section in the docs on Editor SDKs. Should this issue be closed?

@arcanis
Copy link
Member

arcanis commented Jan 30, 2020

Do you agree that it's an issue, or should editors be able to access $$virtual somehow?

It's an issue in that I don't expect editors to support the $$virtual file pattern as their encoding is a bit of a Yarn implementation detail, but I can't find any better tool we can use at the moment.

Closing this issue as there's nothing actionable on our side at the moment (for people reaching this, please upvote microsoft/vscode#75559 to show your interest to the VSCode team).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external bug This issue highlights a bug in another project
Projects
None yet
Development

No branches or pull requests

3 participants