-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Adds support for zip archives #99486
Conversation
export const zip = 'zip'; | ||
|
||
export const supportedSchemes = [ | ||
file, | ||
untitled, | ||
walkThroughSnippet | ||
walkThroughSnippet, | ||
zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary and will be replaced by the strategy described in the description, if greenlighted.
This proposed solution is a step in the right direction. As you noted, the failure mode of this change is that the entire TS server crashes (and such crashes would result in difficult to investigate issues being opened against VS Code). With your proposed change, how is the zip support actually implemented? A server plugin? A patched version of the server? In either case, we need to be able to guarantee that the server can handle the file before we send it over. |
There are two key components:
I think my proposal would work, because:
The only problematic case would be people with the extension, without the SDK, still using a custom |
Ping? 😊 |
Thanks for the details. Now I understand that you are proxying tsserver.js itself rather than shipping a ts server plugin. Have you talked with the TypeScript team about a better solution that could potentially be easily leveraged by other editors as well? Also if a user runs |
I already have one critical PR opened there, the circumstances make it difficult for me to justify maintaining another one at the moment until this one gets solved first 😕
This would enter into the "[...] and if the local SDK is enabled" case I mentioned in the OP. Basically, if the user selects a different TS than the one pointed by the tsdk setting, |
@arcanis I suggest following up more with the TS Team. It would be very nice if you did not have to patch tsserver like this The case I'm concerned about:
With the proposal I don't currently understand how we'd enforce that |
In this situation we wouldn't be able to enforce it, although that would be the result of a specific user configuration, which I think is in a large part the user's responsibility. In a sense, I feel like this isn't unlike what would happen if the user was to point |
That case is easy to trigger using the My preference would be that the TypeScript server itself tells us which types of files it supports. If that will not work, then we need a contribution point that says: for this specific tsdk path, enable this set of file schemes. To be honest this whole proposal feels weird because, as far as I know, you would be the only consumer of any new extension point. VS Code would get bugs reports related to it and have to maintain but we would not be testing or dogfooding it. This sounds like a good opportunity to make TS work better with yarn2 out of the box (or at least add proper extension points so that it can do so) |
Trust me, if I believed I could do it, I'd be already working on it! I'm not afraid of contributing to codebases that aren't mine. Unfortunately, my understanding of the situation is that the TS team doesn't plan on implementing extension points until they're sure they would satisfy every possible use case, and in practical terms I'm afraid that means "probably never".
This is only true on some degree. After all, #59650 got created ~2 years ago by people with no relation to Yarn, and it's a significant problem for the virtual filesystem API in general. Perhaps there isn't anyone else that would benefit from this work at the moment simply because noone else could extract enough value from virtual filesystems without TS support?
I see - in my case there is no node_modules, so I didn't consider that VSCode would propose it as well - but that's not a problem, is it? It's just a matter of checking that the currently selected VSCode module path matches the one configured in the // Instead of
return currentActiveTsdk !== builtin.tsdk ? defaultSchemes + customSchemes : defaultSchemes;
// Prefer
return currentActiveTsdk === typescript.tsdk ? defaultSchemes + customSchemes : defaultSchemes; |
Yes we need someone to drive a discussion with TypeScript about what the proper solution would be for #59650. Maybe TS needs to delegate certain file reads back to clients like VS Code for example. Patching the tsserver though is not scalable Can you link to where this has been discussed with TS previously? Would microsoft/TypeScript#35206 cover your use case? |
This comment (also kinda echoed by microsoft/TypeScript#28289 (comment)) expressed the intent of finding a general purpose solution (it was also mentioned in a prior meeting I had with the TS team). Plugins are discussed on #16607 and #38736; they were still investigated in the 3.5, 3.6, 3.7, 3.8 roadmaps, but disappeared from the 3.9. I imagine this was intentional and they decided it would be too much work, although I don't have details.
Not entirely, as it only covers native PnP resolution, not the part where TypeScript is able to load files from different protocols (it's not a problem when going through our SDK because it works transparently, but for a no-proxy approach TS would have to implement both resolution and filesystem hooks). |
I talked with the TypeScript team this morning about this. We think that this needs more thought. We are concerned that the current approach will spawn bugs that are difficult to triage (such as microsoft/TypeScript#39331 which took one of our engineers half a day to track down). The current yarn approach to proxying and patching tsserver seems like it is going to cause problems down the road, both for users and for us as maintainers More broadly though, we'd like to see how all the current proposals around modules evolve. The root cause of these issue is that yarn 2 introduced a non-standardized solution to modules. Hopefully whatever is standardized can also be applied to or adopted by yarn. That would be the ideal outcome. As a last resort, TypeScript would be open to adding functionality to enable reading files from VS Code file system providers. This would benefit other virtual file system providers as well. Again though, this would only be a last resort and definitely make sure to talk with the TS team before looking into this. Sorry to have to say no to what I know seems like a very small change. |
As you can imagine, we feel very disappointed and let down, which is never a good feeling - even less when you believe you're working for the embetterment of an ecosystem. I know this isn't on you, and I appreciate receiving a straight answer. |
This PR fixes yarnpkg/berry#1157. It also helps with #59650.
Thanks to #94986 we can open VSCode-supported virtual paths when returned by VSCode. However, we still can't send virtual paths to TS. As a result, while we can jump into a zip archive, we can't jump from there to other files.
My diff is a WIP aiming to make that possible. It's working, but I need input from @mjbvz and team to decide how you wish to proceed regarding the configuration part: since TS doesn't support virtual protocols out of the box, and crashes when provided one, we need a way to keep this behaviour gated.
My suggestion
I plan to implement a
typescript.schemes
configuration variable that, when set, adds a set of additional schemes on top of the ones defined inisSupportedScheme
. This setting will only be taken into account if the user has also set atypescript.tsdk
variable AND if the local SDK is enabled. By doing this we ensure that such schemes will only ever be active on TypeScript instances that support them.@mjbvz Does that sound good to you?