-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Allow --watchFactory option that uses user specified plugin for watching files and directories #54012
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
Conversation
|
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, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary |
8bfc8c4 to
4f05278
Compare
It shows that some of the watches couldnt be overriden before project is created
|
@typescript-bot pack this |
|
Heya @sheetalkamat, I've started to run the tarball bundle task on this PR at 4ca063f. You can monitor the build here. |
|
Hey @sheetalkamat, I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
|
Since #54662 is not merged, closing this for now |
With this change we allow users to use custom
watchFactoryplugin either on command line or in editorFor plugin writers the plugin is expected to be module that returns the factory with methods to
watchFileandwatchDirectoryThis behaves similar to language service plugin as in user can have this set in
tsconfig.jsoninwatchOptionsaswatchFactory, pass it on command line during batch compilation or set in vscode's globalwatchOptionsFrom commandline the
watchFactoryoptions is honored only if running with passing--allowPluginsflag.watchFactoryoption can either be module name to look for or it can bePluginImportwhich is object literal with propertynamethat is resolved as name and the object literal is passed on to the factory.The changes in PR include:
watchFactoryinwatchOptionsthat takes in eitherstringorobject literal. The name of the factory needs to be package name to resolve (just like our LS plugins`watchFileorwatchDirectorywe look for this resolved module and use the specific function if available.onConfigurationChangedsimilar to we call for LS plugins when editor uses protocol to do so.Here are some of the prototypes for
watchFactoryplugins:Watching using parcel watcher: https://github.com/sheetalkamat/typescript-parcel-watcher
With this you can run
tsc --watchFactory typescript-parcel-watcheror settypescript-parcel-watcheras option in the vscode's watchOptions preferencesIf using session events and custom command in vscode Changes to vscode to support watchFactory sheetalkamat/vscode#1

You would need the plugin and updated vscode version per PR so that plugin registers custom commands and uses events to communicate through tsserver. You would also need to set watchOptions in vscode preferences to
typescript-vscode-watcherWatching using vscode extension and plugin https://github.com/sheetalkamat/vscode-tsserver-watcher-plugin

Here the watching happens by creating a separate server connection between plugin and extension to do the vscode native watching. For this you would need extension, plugin and to set
vscode-tsserver-watcher-pluginaswatchOptionspreferences in vscode. Note that this would also set the plugin as global plugin (which would in turn fail as global plugin since it does not return the LS in as part ofcreatecall. Vscode could make watchFactory extension take a flag in contributes settings that doesnt pass the plugin as global plugin as well. But this is just prototype so.