-
Notifications
You must be signed in to change notification settings - Fork 110
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
Adding Yarn 2 PnP support #394
base: master
Are you sure you want to change the base?
Conversation
This patch allows tide to jump to files stored in zip packages (in Yarn 2 cache) using Emacs arc-mode. See ananthakumaran#388 (This PR replaces closed PR ananthakumaran#392)
I don't know much about what yarn 2 pnp means, so it would be nice if you can add more info about it in the PR description. Specially want to know if it follows any special file name convention etc. |
@ananthakumaran Thank you for the tide mode, and for your reply to this "accidental PR"! To me tide was (and still is) the first proper environment for JavaScript development (via typescript of-course). And, yarn 2 is the first proper node package management tool - it ticks most of my boxes, including sensible architecture and zero install philosophy on which "PnP" concept is based. There are many searchable reviews and debates on yarn 2 subject on the Internet. Here I am just assuming that it would be great if at some stage tide could play well with certain yarn 2 peculiarities out-of-the-box :) To start tide with yarn 2, the following (or similar) emacs config is required: (setq-local tide-tsserver-executable
;; assuming that `project-root', the path to yarn 2 repository, is defined elsewhere
(concat project-root
"/.yarn/sdks/typescript/bin/tsserver")) a Yarn 2 eliminates recursive
Each external node package (not necessarily from npm) is stored in zip archive. Those archives can be uploaded to SCM (e.g. git) together with the repository source code - thus zero install - just clone and build node repository or the whole monorepository. This node packages structure is called PnP in yarn 2 talk. The following screenshot shows how tide sees files in such zip packages (notice “next” path in dir tree above and on the screenshot in eldoc): If we strip The code proposed in this PR does two things:
What I do not understand here is how to correctly treat |
I found what is the purpose of and in yarn 2 code: Basically, the virtual part of the package path is used in yarn 2 to track peerDependencies. To get the real package file path it is ok to strip the virtual part - that is what this PR does. |
I too am a fan of both tide and yarn2. Would like to see support in tide. If there's anything I can do to help, test, debug, whatever, LMK. |
Does this have a chance of getting merged in? It'd be nice to have Yarn 2 support without having to maintain one's own local fork. |
I'm not opposed to adding yarn-support to tide, but for the maintainers to merge this I think we would need at least the following 3 things:
Basically the current form of this PR puts the burden of all those things onto the maintainers, instead of the contributor, and that's often the number one reason for closed PRs. So anything which lowers the effort required to "OK" this is probably going to help this get merged. |
As it turns out, The algorithm explained by arcanis at the link above is quite simple - we just need to implement it in elisp. Otherwise, I have been using this patch via The major limitation of this patch is that once inside a yarn 2 package archive, tide does not work there and if one needs to navigate/refactor/etc. within packages she would need to unplug them first. I do not know, even conceptually, how to make tide (or lsp) work from within archives... @josteink thank you for the points outlining contribution requirements - I will try to find a bit of time to follow them... |
This patch allows tide to jump to files stored in zip packages (in Yarn 2 cache)
using Emacs arc-mode.
See #388
(This PR replaces closed PR #392)