-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Allow --watchFactory option that uses user specified plugin for watching files and directories #54012
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
watchFactory
plugin either on command line or in editorFor plugin writers the plugin is expected to be module that returns the factory with methods to
watchFile
andwatchDirectory
This behaves similar to language service plugin as in user can have this set in
tsconfig.json
inwatchOptions
aswatchFactory
, pass it on command line during batch compilation or set in vscode's globalwatchOptions
From commandline the
watchFactory
options is honored only if running with passing--allowPlugins
flag.watchFactory
option can either be module name to look for or it can bePluginImport
which is object literal with propertyname
that is resolved as name and the object literal is passed on to the factory.The changes in PR include:
watchFactory
inwatchOptions
that takes in eitherstring
orobject literal
. The name of the factory needs to be package name to resolve (just like our LS plugins`watchFile
orwatchDirectory
we look for this resolved module and use the specific function if available.onConfigurationChanged
similar to we call for LS plugins when editor uses protocol to do so.Here are some of the prototypes for
watchFactory
plugins:Watching using parcel watcher: https://github.com/sheetalkamat/typescript-parcel-watcher
With this you can run
tsc --watchFactory typescript-parcel-watcher
or settypescript-parcel-watcher
as 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-watcher
Watching 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-plugin
aswatchOptions
preferences 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 ofcreate
call. 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.