Skip to content

Commit

Permalink
simplify output messages (#31454)
Browse files Browse the repository at this point in the history
remove all `client/server/middleware only` messages and show `client and server` instead only when both compilers has been used.
  • Loading branch information
sokra authored Nov 16, 2021
1 parent 9375485 commit b79591c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bench/nested-deps/bench.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 2 additions & 6 deletions packages/next/build/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/output/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions packages/next/server/dev/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
18 changes: 12 additions & 6 deletions test/development/basic/hmr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/amphtml/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down
9 changes: 5 additions & 4 deletions test/integration/nullish-config/test/index.test.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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 () => {
Expand All @@ -48,7 +48,7 @@ const runTests = () => {

const stdout = await getStdout()

expect(stdout).toContain('ompiled successfully')
expect(stdout).toMatch(/compiled .*successfully/i)
})
}

Expand All @@ -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
}
})
Expand Down
2 changes: 1 addition & 1 deletion test/lib/next-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit b79591c

Please sign in to comment.