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

tsserver support for a virtual filesystem #48497

Closed
wants to merge 72 commits into from
Closed

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Mar 31, 2022

  1. I moved the virtual file system with watch code to a new project. The server now depends on this new project.
  2. The test of the new server message still needs to move to a separate file.

Edit: Remaining work

  1. Should the plugin system start providing a separate FileServerHost to plugins, or should it create a hybrid host that delegates to a fshost in case it's running in the browser?
  2. The ATA installer assumes that it can run npm install on a local disk. It'll have to be substantially rewritten.
  3. The message-based system won't scale very far -- I want to investigate @jakebailey 's idea for starting an in-browser server to let tsserver request files from vs code.

Partly fixes #47600 -- there is probably more work needed here and definitely in vs code.

@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @amcasey, @mjbvz, @minestarks for you. Feel free to loop in other consumers/maintainers if necessary

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Mar 31, 2022
src/server/editorServices.ts Outdated Show resolved Hide resolved
src/server/editorServices.ts Outdated Show resolved Hide resolved
src/server/editorServices.ts Outdated Show resolved Hide resolved
src/server/protocol.ts Outdated Show resolved Hide resolved
src/server/protocol.ts Outdated Show resolved Hide resolved
src/harness/virtualFileSystemWithWatch.ts Show resolved Hide resolved
src/tsserver/webServer.ts Outdated Show resolved Hide resolved
src/vfs/tsconfig.json Outdated Show resolved Hide resolved
I'm not sure why this fails locally, I suspect I need to `npm ci`.
This removes fshost usage in most places except for construction of
objects.
Instead, pass in additional configuration from TestServerHost
1. Move VirtualServerHost code to correct vfs/harness location.
2. Serialise watch and timeout information.
3. Improve test by modifying an unopened file.
4. Test can run arbitrary actions in addition to commands.
src/server/project.ts Outdated Show resolved Hide resolved
@@ -1748,7 +1747,16 @@ namespace ts.server {
useCaseSensitiveFileNames: this.program.useCaseSensitiveFileNames(),
};
}
return this.projectService.host;
return {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not needed either ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this here to provide a ModuleResolutionHost which uses the projectService's [fs]host for fileExists, directoryExists, realpath, useCaseSensitiveFileNames instead of this.program.fileExists/directoryExists/realpath/useCaseSensitiveFileNames. Maybe it's not needed? I don't know.

src/server/editorServices.ts Outdated Show resolved Hide resolved
src/server/editorServices.ts Outdated Show resolved Hide resolved
src/server/session.ts Outdated Show resolved Hide resolved
src/server/types.ts Outdated Show resolved Hide resolved
1. Reimplement recursive deleting in VirtualServerHost.deleteFile
2. Save a private fshost, then all VirtualServerHost methods directly.
3. Switch from asserts to logs when fshost isn't a valid VirtualServerHost.
@sandersn
Copy link
Member Author

This is obsoleted by the virtual filesystem written by the vscode team, and the tsserver host that I wrote for vscode to use it.

@sandersn sandersn closed this Apr 11, 2023
@jimkyndemeyer
Copy link

This is obsoleted by the virtual filesystem written by the vscode team, and the tsserver host that I wrote for vscode to use it.

@sandersn can you provide links to both? Would be interesting to see how the solution was implemented. Thanks :)

@sandersn
Copy link
Member Author

The tsserver host is in vscode's repo at extensions/typescript-language-features/web/tsServer.ts
The initial PR is microsoft/vscode#169311 -- it adds some filesystem packages whose source you can look up on github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Virtual file system support in TSServer
6 participants