From 7a9fd27146b34042051a399ab02a1cb8f1a4b948 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 24 Apr 2024 12:27:47 -0700 Subject: [PATCH] chore: never watch node_modules (#30514) --- packages/playwright/src/fsWatcher.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/playwright/src/fsWatcher.ts b/packages/playwright/src/fsWatcher.ts index 749c11ab0b..c0d4e4d04e 100644 --- a/packages/playwright/src/fsWatcher.ts +++ b/packages/playwright/src/fsWatcher.ts @@ -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')