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
Watch extended configs if present #41493
Watch extended configs if present #41493
Conversation
bdf7c2e
to
ad2fbaa
Compare
053e9b4
to
31f0d50
Compare
31f0d50
to
4d59cc6
Compare
588bee3
to
36c29cb
Compare
d091cb9
to
4224dd7
Compare
|
67dcc8e
to
86905be
Compare
src/compiler/watchUtilities.ts
Outdated
) { | ||
const extendedSourceFiles = configFile.extendedSourceFiles || emptyArray; | ||
// TODO(rbuckton): Should be a `Set` but that requires changing the below code that uses `mutateMap` | ||
const newExtendedConfigFilesMap = arrayToMap(extendedSourceFiles, identity, returnTrue); |
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.
Key needs to be Path, value needs to be file name to watch
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 doesnot create the key with Path
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.
Ah, I missed the meaning of this the first time around. I'll pass something to allow converting from string to Path
.
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.
Will update to correctly account for removals, and add new tests. Had a few questions about latest review.
While creating a test case for removing projects, I noticed that I had not considered the builder's watch logic. I'll replicate the "shared" watcher pattern from the server here as well. |
1acd39c
to
2284a6c
Compare
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.
I have some more feedback but i am going to try fixing some of those myself as that might be easier
src/compiler/watchUtilities.ts
Outdated
) { | ||
const extendedSourceFiles = configFile.extendedSourceFiles || emptyArray; | ||
// TODO(rbuckton): Should be a `Set` but that requires changing the below code that uses `mutateMap` | ||
const newExtendedConfigFilesMap = arrayToMap(extendedSourceFiles, identity, returnTrue); |
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 doesnot create the key with Path
Thank you very much for those suggestions. I merged all of them and then applied the |
Please cherry pick e2d178f as i dont have permission to update your fork. |
Added new `WatchType` for extended config files. Refactored watch map update to separate function, relocated call sites. Removed unnecessary test cases and relocated with new tests in programUpdates.
Update `updateExtendedConfigFilesWatch` to read from a `TsConfigSourceFile` to get `extendedSourceFiles`. Add watcher map to `ConfiguredProject` in the server. New test cases to verify correct events triggered and extended files are being watched properly.
Removes unnecessary actions in extended config watcher callback function. Updates tests to match.
New shared watcher map in ProjectService that stores callbacks per project to be invoked when the file watcher is triggered. The FileWatcher is created with the watch options of the first Project to watch the extended config.
Remove all server-related utility functions/types from watchUtilities. Store config-project mapping and config file watchers inside ProjectService with new private methods to add or remove projects.
Creates SharedExtendedConfigFileWatcher in both editorServices (tsserver) and tsbuildPublic. The file watcher is responsible for triggering a full project reload for the contained projects. Upon reload, any configs that are no longer related to a project have their watchers updated to match. New test cases to confirm that the file watchers for extended configs are closed when the project is closed.
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
3a0c0dd
to
7d25e43
Compare
The unified |
Fixes #17753
Inspects
extendedSourceFiles
fromconfigFile
inCompilerOptions
and starts a watcher for each file. Watch callback invokesscheduleProgramReload
just like the watcher for the main config file. Watcher pattern modelled after watcher map for missing files. Also provides shared watcher map for situations where multiple projects are open at once (tsbuild/tsserver).Added new test cases, including chain of extended configs and ones copied from
watchEnvironment/watchOptions
with extended configs to verify they are being watched.