From 7fb10bbf39cba6f4b66c1865edbb7d7e96d97312 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 15 Nov 2021 18:25:02 +0100 Subject: [PATCH 1/3] simplify output messages --- bench/nested-deps/bench.mjs | 2 +- packages/next/build/output/index.ts | 8 ++------ packages/next/build/output/store.ts | 2 +- packages/next/server/dev/on-demand-entry-handler.ts | 10 +++------- test/integration/amphtml/test/index.test.js | 2 +- test/lib/next-test-utils.js | 2 +- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/bench/nested-deps/bench.mjs b/bench/nested-deps/bench.mjs index b25eba322db0f..d8ad44c23d851 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 859b8a62593af..ecca2387820b3 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 2e0135f631be5..3b2946f04f3ca 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 cc921c8036b53..2c48073142d10 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/integration/amphtml/test/index.test.js b/test/integration/amphtml/test/index.test.js index 82493b71a4160..f32cdde1740fc 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/lib/next-test-utils.js b/test/lib/next-test-utils.js index b834a802eb47c..fd10c90a97858 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 ( From 5174e88167d0a97fadfa315e7be1bb3ffeae65dd Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 15 Nov 2021 20:48:38 +0100 Subject: [PATCH 2/3] update test cases --- test/development/basic/hmr.test.ts | 18 ++++++++++++------ .../nullish-config/test/index.test.js | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/development/basic/hmr.test.ts b/test/development/basic/hmr.test.ts index 162d21db3a8fa..47ef6872fa616 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/nullish-config/test/index.test.js b/test/integration/nullish-config/test/index.test.js index e2f60a21ada96..51916d74ab474 100644 --- a/test/integration/nullish-config/test/index.test.js +++ b/test/integration/nullish-config/test/index.test.js @@ -27,7 +27,7 @@ const runTests = () => { const stdout = await getStdout() - expect(stdout).toContain('ompiled successfully') + expect(stdout).toMatch(/compiled (client and server )?successfully/i) }) it('should ignore configs set to `null` in next.config.js', async () => { From 30b6be70b83fcffce7aa095239a12473552ef462 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 16 Nov 2021 10:42:11 +0100 Subject: [PATCH 3/3] fix test case --- test/integration/nullish-config/test/index.test.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/integration/nullish-config/test/index.test.js b/test/integration/nullish-config/test/index.test.js index 51916d74ab474..9e80d71e1c009 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).toMatch(/compiled (client and server )?successfully/i) + 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 } })