-
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 watch mode to listen to changes below the "longest common directo…
…ry prefix" of relevant files, rather than only files below `process.cwd()`, while keeping event filtering intact (#9267) * 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. * chore: Add `yarn watch:examples` and `dev-test-outer-dir` for watch mode testing This adds a directory "outside" of `dev-test`, and also adds a new script command `yarn watch:examples` which is the "watch mode" equivalent of `yarn generate:examples`. It adds a dependency on a `githunt` document in `dev-test-outer-dir`, and if all is working as expected, you should be able to edit this file while in watch mode to trigger a rebuild, and it should also be included in build mode. That is, if you run `yarn generate:examples`, or `yarn watch:examples`, there should be no changes to the Git repo.
- Loading branch information
1 parent
6e3fd38
commit 1837493
Showing
7 changed files
with
95 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# When running `yarn watch:examples`, updating this file should trigger rebuild, | ||
# even though it's "outside" of the CWD of `dev-test/codegen.ts` | ||
query CurrentUserForProfileFromOutsideDirectory { | ||
currentUser { | ||
login | ||
avatar_url | ||
} | ||
} |
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
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
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
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
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