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 does not resolve tsconfig's paths in VSCode #3117

Closed
1 task
micaelmbagira opened this issue Jul 13, 2021 · 10 comments · Fixed by #3297
Closed
1 task

[Bug]: Pnpify does not resolve tsconfig's paths in VSCode #3117

micaelmbagira opened this issue Jul 13, 2021 · 10 comments · Fixed by #3297
Labels
bug Something isn't working upholded Real issues without formal reproduction

Comments

@micaelmbagira
Copy link

Self-service

  • I'd be willing to implement a fix

Describe the bug

  • I have a Typescript monorepo with nx and yarn PnP
  • VSCode is configured according to the documentation using yarn dlx @yarnpkg/pnpify --sdk vscode and changing the workspace version to 4.2.4-pnpify

Expected
VSCode is able to resolve the typings of external dependencies (e.g. rxjs) and local dependencies (e.g. Nx library, using the tsconfig.json's paths configuration).

Actual

  • VSCode is able to resolve the typings of external dependencies
  • VSCode is not able to resolve local dependencies and throws the error Cannot find module '@issue-yarn-pnp-vscode-nx/foo' or its corresponding type declarations.ts(2307) (see screenshot)

Notes

  • However, changing VSCode's TS version to the default one results in VSCode not able to resolve external dependencies but able to resolve local dependencies
  • the problem is only in VSCode because running yarn nx build bar --with-deps works and typescript is able to resolve the dependencies

Screenshot 2021-07-13 at 21 30 54

To reproduce

Here is a very simple repo that reproduces the issue https://github.com/micaelmbagira/issue-yarn-pnp-vscode-nx

Environment

  System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
  Binaries:
    Node: 14.16.0 - /private/var/folders/07/fjm413m14h1dwkpqyd0tps5h0000gn/T/xfs-d934ada9/node
    Yarn: 2.4.2 - /private/var/folders/07/fjm413m14h1dwkpqyd0tps5h0000gn/T/xfs-d934ada9/yarn
    npm: 7.11.2 - ~/.config/yarn/global/node_modules/.bin/npm

Additional context

No response

@micaelmbagira micaelmbagira added the bug Something isn't working label Jul 13, 2021
@merceyz
Copy link
Member

merceyz commented Jul 13, 2021

paths isn't supported at the moment and we suggest using the link: protocol instead, see https://yarnpkg.com/features/protocols/#why-is-the-link-protocol-recommended-over-aliases-for-path-mapping

@micaelmbagira
Copy link
Author

@merceyz where is it not supported exactly, in @yarnpkg/pnpify? Because the issue only happens in VSCode.

@yarnbot
Copy link
Collaborator

yarnbot commented Aug 12, 2021

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟

@yarnbot yarnbot added the stale Issues that didn't get attention label Aug 12, 2021
@micaelmbagira
Copy link
Author

micaelmbagira commented Aug 13, 2021

Up, the issue is reproducible (a repo has been linked in the issue).

@merceyz merceyz added upholded Real issues without formal reproduction and removed stale Issues that didn't get attention labels Aug 19, 2021
@merceyz
Copy link
Member

merceyz commented Aug 19, 2021

After digging into #3231 I see this is the same issue and not what I initially thought it was, sorry about that.

Will be fixed by #3297, you can try the fix before release by running

yarn set version from sources --branch 3231 && yarn

@micaelmbagira
Copy link
Author

@merceyz @arcanis Thanks, now that the branch has been merged, do I need to set the version from master or has a new version already been released?

@micaelmbagira
Copy link
Author

@merceyz Just tried with master and the TS Server in VSCode crashes

[Info  - 13:11:23.411] <syntax> Forking...
[Info  - 13:11:23.414] <syntax> Starting...
[Info  - 13:11:23.414] <semantic> Forking...
[Info  - 13:11:23.416] <semantic> Starting...
[Error  - 13:11:23.535] TSServer exited with code: 0. Signal: null
[Info  - 13:11:23.620] Starting TS Server 
[Info  - 13:11:23.620] Not starting server. Too many crashes.
[Info  - 13:11:24.27] Starting TS Server 
[Info  - 13:11:24.27] Not starting server. Too many crashes.
[Info  - 13:11:24.688] Starting TS Server 

@merceyz
Copy link
Member

merceyz commented Aug 31, 2021

Thanks, now that the branch has been merged, do I need to set the version from master

Not if you already used the PR

has a new version already been released?

I just started a release build so in about 10 minutes you can use the latest canary version

yarn set version canary

https://github.com/yarnpkg/berry/actions/runs/1186470907

Just tried with master and the TS Server in VSCode crashes

I cloned your repo and tested with master and it works after updating the SDK with

yarn dlx @yarnpkg/sdks vscode

@micaelmbagira
Copy link
Author

@merceyz I confirm that it works now, thanks, this one will unblock all the Nx users!!

@micaelmbagira
Copy link
Author

@merceyz when do you plan to release this bugfix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upholded Real issues without formal reproduction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants