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
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/vite/src/node/index.ts
Expand Up @@ -82,3 +82,4 @@ export type { FSWatcher, WatchOptions } from 'types/chokidar'
export type { Terser } from 'types/terser'
export type { RollupCommonJSOptions } from 'types/commonjs'
export type { RollupDynamicImportVarsOptions } from 'types/dynamicImportVars'
export type { Matcher, AnymatchPattern, AnymatchFn } from 'types/anymatch'
6 changes: 5 additions & 1 deletion packages/vite/src/node/server/index.ts
Expand Up @@ -319,7 +319,11 @@ export async function createServer(

const { ignored = [], ...watchOptions } = serverConfig.watch || {}
const watcher = chokidar.watch(path.resolve(root), {
ignored: ['**/node_modules/**', '**/.git/**', ...ignored],
ignored: [
'**/node_modules/**',
'**/.git/**',
...(Array.isArray(ignored) ? ignored : [ignored])
],
ignoreInitial: true,
ignorePermissionErrors: true,
disableGlobbing: true,
Expand Down
5 changes: 5 additions & 0 deletions packages/vite/types/anymatch.d.ts
@@ -0,0 +1,5 @@
export type AnymatchFn = (testString: string) => boolean
export type AnymatchPattern = string | RegExp | AnymatchFn
type AnymatchMatcher = AnymatchPattern | AnymatchPattern[]

export { AnymatchMatcher as Matcher }
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion packages/vite/types/chokidar.d.ts
Expand Up @@ -29,6 +29,7 @@ THE SOFTWARE.
/// <reference types="node" />

import * as fs from 'fs'
import { Matcher } from './anymatch'

export interface FSWatcher extends fs.FSWatcher {
options: WatchOptions
Expand Down Expand Up @@ -117,7 +118,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?: Matcher

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