chore: never watch node_modules (#30514)

This commit is contained in:
Pavel Feldman 2024-04-24 12:27:47 -07:00 committed by GitHub
parent 8fc7723f22
commit 7a9fd27146
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,6 +16,7 @@
import { chokidar } from './utilsBundle';
import type { FSWatcher } from 'chokidar';
import path from 'path';
export type FSEvent = { event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string };
@ -51,7 +52,8 @@ export class Watcher {
if (!this._watchedFiles.length)
return;
this._fsWatcher = chokidar.watch(watchedFiles, { ignoreInitial: true, ignored: this._ignoredFolders }).on('all', async (event, file) => {
const ignored = [...this._ignoredFolders, (name: string) => name.includes(path.sep + 'node_modules' + path.sep)];
this._fsWatcher = chokidar.watch(watchedFiles, { ignoreInitial: true, ignored }).on('all', async (event, file) => {
if (this._throttleTimer)
clearTimeout(this._throttleTimer);
if (this._mode === 'flat' && event !== 'add' && event !== 'change')