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

Enable TS Server plugins on web #47376

Closed
mjbvz opened this issue Jan 11, 2022 · 5 comments · Fixed by #47377
Closed

Enable TS Server plugins on web #47376

mjbvz opened this issue Jan 11, 2022 · 5 comments · Fixed by #47377
Assignees
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 11, 2022

For microsoft/vscode#140455

A few key VS Code extensions — such as IntelliCode — are powered by TS Server plugins. Currently we don't support loading these plugins at all on web versions of TypeScript

This feature request tracks enabling plugins from extensions on vscode.dev and GitHub.dev. We don't plan to support plugins from the workspace since these require running npm install

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 11, 2022

At the moment VS Code doesn't even try to initialize plugins with the server. However once I remove this check on the VS Code side, the code starts failing at require not being implemented:

require: () => ({ module: undefined, error: new Error("Not implemented") }),

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 11, 2022

I wonder if we need a browser version of these plugins too, similar to what VS Code does for extensions in browsers

  • We wouldn't try executing code the relies on node. Instead plugin authors would have to opt-in
  • Authors could easily vary their implementation between node and browser
  • We could require the plugin be compiled to a single file, just like we do for vscode extensions in browsers

mjbvz added a commit to mjbvz/TypeScript that referenced this issue Jan 11, 2022
This is a first exploration for  microsoft#47376 microsoft/vscode#140455

It implements a very basic version of `require` for the web that lets us load plugins with a very specific structure. `require` being sync limits our options here, so I'm using `importScripts` plus a global to get the exports of a plugin. The plugin must also be compiled down to a single file at the moment
@RyanCavanaugh RyanCavanaugh added Committed The team has roadmapped this issue Suggestion An idea for TypeScript labels Jan 13, 2022
@mjbvz
Copy link
Contributor Author

mjbvz commented Feb 16, 2022

I've cleaned up my prototype in #47377 quite a bit. Noteworthy changes:

  • Plugins are now only loaded if they have a browser field in their package.json
  • Plugins are loaded using import(...) in web
  • Plugins on web must be compiled to a module that can be imported

I think web enabled plugins are good opportunity to move plugins to adopt modern JS practices. Trying to load plugins synchronously on web is also very ugly as my original prototype showed

@leti367
Copy link
Member

leti367 commented Jun 16, 2022

Thanks all for the help. @rbuckton Since this change is already merged, do you have any idea when would this be available?

@RyanCavanaugh
Copy link
Member

PRs merged today will be in the nightly build starting immediately the following day, and also in 4.8 Beta (plus any subsequent release)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants