From b79591cdaf78e4bdebaa714d55e745419ad5d079 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 16 Nov 2021 16:57:30 +0100 Subject: [PATCH] simplify output messages (#31454) remove all `client/server/middleware only` messages and show `client and server` instead only when both compilers has been used. --- bench/nested-deps/bench.mjs | 2 +- packages/next/build/output/index.ts | 8 ++------ packages/next/build/output/store.ts | 2 +- .../next/server/dev/on-demand-entry-handler.ts | 10 +++------- test/development/basic/hmr.test.ts | 18 ++++++++++++------ test/integration/amphtml/test/index.test.js | 2 +- .../nullish-config/test/index.test.js | 9 +++++---- test/lib/next-test-utils.js | 2 +- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/bench/nested-deps/bench.mjs b/bench/nested-deps/bench.mjs index b25eba322db0fb2..d8ad44c23d851fd 100644 --- a/bench/nested-deps/bench.mjs +++ b/bench/nested-deps/bench.mjs @@ -110,7 +110,7 @@ function runNextCommandDev(argv, opts = {}) { function handleStdout(data) { const message = data.toString() const bootupMarkers = { - dev: /compiled successfully/i, + dev: /compiled .*successfully/i, start: /started server/i, } if ( diff --git a/packages/next/build/output/index.ts b/packages/next/build/output/index.ts index 859b8a62593af33..ecca2387820b300 100644 --- a/packages/next/build/output/index.ts +++ b/packages/next/build/output/index.ts @@ -139,12 +139,8 @@ buildStore.subscribe((state) => { loading: false, typeChecking: false, partial: - clientWasLoading && !serverWasLoading && !serverWebWasLoading - ? 'client' - : serverWasLoading && !clientWasLoading && !serverWebWasLoading - ? 'server' - : serverWebWasLoading && !clientWasLoading && !serverWasLoading - ? 'serverWeb' + clientWasLoading && (serverWasLoading || serverWebWasLoading) + ? 'client and server' : undefined, modules: (clientWasLoading ? client.modules : 0) + diff --git a/packages/next/build/output/store.ts b/packages/next/build/output/store.ts index 2e0135f631be553..3b2946f04f3ca9f 100644 --- a/packages/next/build/output/store.ts +++ b/packages/next/build/output/store.ts @@ -15,7 +15,7 @@ export type OutputState = | { loading: false typeChecking: boolean - partial: 'client' | 'server' | 'serverWeb' | undefined + partial: 'client and server' | undefined modules: number errors: string[] | null warnings: string[] | null diff --git a/packages/next/server/dev/on-demand-entry-handler.ts b/packages/next/server/dev/on-demand-entry-handler.ts index cc921c8036b53e8..2c48073142d10fc 100644 --- a/packages/next/server/dev/on-demand-entry-handler.ts +++ b/packages/next/server/dev/on-demand-entry-handler.ts @@ -259,13 +259,9 @@ export default function onDemandEntryHandler( if (entriesChanged) { reportTrigger( - isApiRoute - ? `${normalizedPage} (server only)` - : isMiddleware - ? `${normalizedPage} (middleware only)` - : clientOnly - ? `${normalizedPage} (client only)` - : normalizedPage + isApiRoute || isMiddleware || clientOnly + ? normalizedPage + : `${normalizedPage} (client and server)` ) invalidator.invalidate() } diff --git a/test/development/basic/hmr.test.ts b/test/development/basic/hmr.test.ts index 162d21db3a8fa10..47ef6872fa61620 100644 --- a/test/development/basic/hmr.test.ts +++ b/test/development/basic/hmr.test.ts @@ -57,9 +57,11 @@ describe('basic HMR', () => { expect(next.cliOutput.slice(start)).toContain('compiling...') expect(next.cliOutput.slice(start)).toContain( - 'compiling /hmr/contact...' + 'compiling /hmr/contact (client and server)...' + ) + expect(next.cliOutput).toContain( + 'compiling /_error (client and server)...' ) - expect(next.cliOutput).toContain('compiling /_error...') } finally { if (browser) { await browser.close() @@ -327,9 +329,11 @@ describe('basic HMR', () => { ) expect(next.cliOutput.slice(start)).toContain( - 'compiling /hmr/new-page...' + 'compiling /hmr/new-page (client and server)...' + ) + expect(next.cliOutput).toContain( + 'compiling /_error (client and server)...' ) - expect(next.cliOutput).toContain('compiling /_error...') } catch (err) { await next.deleteFile(newPage) throw err @@ -358,9 +362,11 @@ describe('basic HMR', () => { await check(() => getBrowserBodyText(browser), /This is the about page/) expect(next.cliOutput.slice(start)).toContain( - 'compiling /hmr/about2...' + 'compiling /hmr/about2 (client and server)...' + ) + expect(next.cliOutput).toContain( + 'compiling /_error (client and server)...' ) - expect(next.cliOutput).toContain('compiling /_error...') } catch (err) { await next.patchFile(aboutPage, aboutContent) if (browser) { diff --git a/test/integration/amphtml/test/index.test.js b/test/integration/amphtml/test/index.test.js index 82493b71a4160c7..f32cdde1740fcab 100644 --- a/test/integration/amphtml/test/index.test.js +++ b/test/integration/amphtml/test/index.test.js @@ -519,7 +519,7 @@ describe('AMP Usage', () => { }) it('should not contain missing files warning', async () => { - expect(output).toContain('compiled successfully') + expect(output).toContain('compiled client and server successfully') expect(output).toContain('compiling /only-amp') expect(output).not.toContain('Could not find files for') }) diff --git a/test/integration/nullish-config/test/index.test.js b/test/integration/nullish-config/test/index.test.js index e2f60a21ada96d6..9e80d71e1c009cb 100644 --- a/test/integration/nullish-config/test/index.test.js +++ b/test/integration/nullish-config/test/index.test.js @@ -1,7 +1,7 @@ /* eslint-env jest */ import fs from 'fs-extra' import { join } from 'path' -import { launchApp, findPort, nextBuild } from 'next-test-utils' +import { launchApp, findPort, nextBuild, killApp } from 'next-test-utils' const appDir = join(__dirname, '..') const nextConfig = join(appDir, 'next.config.js') @@ -27,7 +27,7 @@ const runTests = () => { const stdout = await getStdout() - expect(stdout).toContain('ompiled successfully') + expect(stdout).toMatch(/compiled .*successfully/i) }) it('should ignore configs set to `null` in next.config.js', async () => { @@ -48,7 +48,7 @@ const runTests = () => { const stdout = await getStdout() - expect(stdout).toContain('ompiled successfully') + expect(stdout).toMatch(/compiled .*successfully/i) }) } @@ -59,11 +59,12 @@ describe('Nullish configs in next.config.js', () => { beforeAll(() => { getStdout = async () => { let stdout = '' - await launchApp(appDir, await findPort(), { + const app = await launchApp(appDir, await findPort(), { onStdout: (msg) => { stdout += msg }, }) + await killApp(app) return stdout } }) diff --git a/test/lib/next-test-utils.js b/test/lib/next-test-utils.js index b834a802eb47c30..fd10c90a97858d8 100644 --- a/test/lib/next-test-utils.js +++ b/test/lib/next-test-utils.js @@ -240,7 +240,7 @@ export function runNextCommandDev(argv, stdOut, opts = {}) { function handleStdout(data) { const message = data.toString() const bootupMarkers = { - dev: /compiled successfully/i, + dev: /compiled .*successfully/i, start: /started server/i, } if (