Skip to content
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

fix: Matcher for chokidar WatchOptions#ignored #4616

Merged
merged 3 commits into from Aug 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vite/types/chokidar.d.ts
Expand Up @@ -117,7 +117,7 @@ export interface WatchOptions {
* (the path), second time with two arguments (the path and the
* [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
*/
ignored?: any
ignored?: string[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ignored can also be of type string when only one entry is needed, or a regex. I don't find proper docs for it, maybe it is better to first send this change to chokidar so it is properly discussed there, and then we can port it here?

Copy link
Contributor Author

@hyf0 hyf0 Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. But it seems to introduce another problem. we make the assumption that it is just an array. It will be throw error '/foo/ is not iterable' if the user just writes ignore: /foo/.

const { ignored = [], ...watchOptions } = serverConfig.watch || {}
const watcher = chokidar.watch(path.resolve(root), {
ignored: ['**/node_modules/**', '**/.git/**', ...ignored],

I will close this and open another PR to fix it. Thanks for all the guidance.


/**
* If set to `false` then `add`/`addDir` events are also emitted for matching paths while
Expand Down