From 1d279cfbc4f19aef614e6a0b0e4ec55dc6b6eb7d Mon Sep 17 00:00:00 2001 From: 9aoy Date: Fri, 29 Nov 2024 14:49:30 +0800 Subject: [PATCH] perf: lazy import chokidar (#494) --- packages/core/src/cli/restart.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/cli/restart.ts b/packages/core/src/cli/restart.ts index 667393b15..934418840 100644 --- a/packages/core/src/cli/restart.ts +++ b/packages/core/src/cli/restart.ts @@ -1,5 +1,4 @@ import path from 'node:path'; -import chokidar from 'chokidar'; import { color, debounce, isTTY } from '../utils/helper'; import { logger } from '../utils/logger'; @@ -11,11 +10,12 @@ export async function watchFilesForRestart( return; } + const chokidar = await import('chokidar'); + const watcher = chokidar.watch(files, { ignoreInitial: true, // If watching fails due to read permissions, the errors will be suppressed silently. ignorePermissionErrors: true, - ignored: ['**/node_modules/**', '**/.git/**', '**/.DS_Store/**'], }); const callback = debounce(