-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Listen for file changes in watch mode in longest common directory
Prior to #9009, which moved from Chokidar to `@parcel/watcher`, the behavior was to watch for all relevant files. However, since switching to `@parcel/watcher`, the new behavior has been to watch all files below `process.cwd()`, and then filter the change events for only the relevant files. This approach works fine, except that it's possible for a valid config to reference paths outside of the current working directory (e.g. `documents: "../some-other/*.graphql`), and these paths are included in build mode, but were not being included in watch mode because they're outside of `process.cwd()`. This commit adds logic, after parsing all relevant file paths, to find the "longest common directory prefix" of all those file paths, i.e. the "highest" (closest to `/`) directory that contains all the relevant file paths. Then, when subscribing to the Parcel watcher, this directory is used instead of `process.cwd()`. For example, the longest common directory of the paths `/foo/bar/*.graphql` and `/foo/fizz/*.graphql` would be `/foo`. Note that the filtering behavior is left unchanged, and this only affects the root path given to the Parcel watcher. When an event is received, the filtering can still filter out irrelevant paths, including those filtered by `config.watchPattern` if it's defined.
- Loading branch information
1 parent
6e3fd38
commit 4e171d2
Showing
2 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-codegen/cli': patch | ||
--- | ||
|
||
Fix watch mode to listen to longest common directory prefix of relevant files, rather than only files below the current working directory (fixes #9266). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters