From 7463512d97d7dd3c06da711dd91b208bdb811745 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 23 Aug 2023 13:55:15 -0600 Subject: [PATCH 1/2] feat: decreased aggregate timeout --- .../next/src/server/lib/router-utils/setup-dev.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/next/src/server/lib/router-utils/setup-dev.ts b/packages/next/src/server/lib/router-utils/setup-dev.ts index 1a2f5f782de75..cfcf0ceee4a87 100644 --- a/packages/next/src/server/lib/router-utils/setup-dev.ts +++ b/packages/next/src/server/lib/router-utils/setup-dev.ts @@ -87,6 +87,20 @@ import { MiddlewareManifest } from '../../../build/webpack/plugins/middleware-pl import { devPageFiles } from '../../../build/webpack/plugins/next-types-plugin/shared' import type { RenderWorkers } from '../router-server' +/** + * This is the timeout for which the watchpack will emit the `aggregate` event + * after file changes are made. This is to prevent unnecessary rebuilds when + * multiple files are changed at once. + * + * This defaults to a value, but can be overridden by setting the + * `NEXT_DEV_WATCHPACK_AGGREGATE_TIMEOUT` environment variable to a value in + * milliseconds. For example, to set the timeout to 100 milliseconds: `100`. + */ +const WATCHPACK_AGGREGATE_TIMEOUT = process.env + .NEXT_DEV_WATCHPACK_AGGREGATE_TIMEOUT + ? parseInt(process.env.NEXT_DEV_WATCHPACK_AGGREGATE_TIMEOUT, 10) + : 50 + type SetupOpts = { renderWorkers: RenderWorkers dir: string @@ -780,6 +794,7 @@ async function startWatcher(opts: SetupOpts) { files.push(...tsconfigPaths) const wp = new Watchpack({ + aggregateTimeout: WATCHPACK_AGGREGATE_TIMEOUT, ignored: (pathname: string) => { return ( !files.some((file) => file.startsWith(pathname)) && From 06d5b2c19b6520e9899867e3bb02448a76f91146 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 23 Aug 2023 14:04:54 -0600 Subject: [PATCH 2/2] fix: removed environment variable option --- packages/next/src/server/lib/router-utils/setup-dev.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/next/src/server/lib/router-utils/setup-dev.ts b/packages/next/src/server/lib/router-utils/setup-dev.ts index cfcf0ceee4a87..6c97a3ecf7a5d 100644 --- a/packages/next/src/server/lib/router-utils/setup-dev.ts +++ b/packages/next/src/server/lib/router-utils/setup-dev.ts @@ -91,15 +91,8 @@ import type { RenderWorkers } from '../router-server' * This is the timeout for which the watchpack will emit the `aggregate` event * after file changes are made. This is to prevent unnecessary rebuilds when * multiple files are changed at once. - * - * This defaults to a value, but can be overridden by setting the - * `NEXT_DEV_WATCHPACK_AGGREGATE_TIMEOUT` environment variable to a value in - * milliseconds. For example, to set the timeout to 100 milliseconds: `100`. */ -const WATCHPACK_AGGREGATE_TIMEOUT = process.env - .NEXT_DEV_WATCHPACK_AGGREGATE_TIMEOUT - ? parseInt(process.env.NEXT_DEV_WATCHPACK_AGGREGATE_TIMEOUT, 10) - : 50 +const WATCHPACK_AGGREGATE_TIMEOUT = 5 type SetupOpts = { renderWorkers: RenderWorkers