Unverified Commit 09772c3a authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

[cache components] add cache components indicator to dev start (#85069)

Missed the plumbing for this in `dev`.
parent 34a40fd9
...@@ -367,10 +367,12 @@ export async function startServer( ...@@ -367,10 +367,12 @@ export async function startServer(
// Only load env and config in dev to for logging purposes // Only load env and config in dev to for logging purposes
let envInfo: string[] | undefined let envInfo: string[] | undefined
let experimentalFeatures: ConfiguredExperimentalFeature[] | undefined let experimentalFeatures: ConfiguredExperimentalFeature[] | undefined
let cacheComponents: boolean | undefined
try { try {
if (isDev) { if (isDev) {
const startServerInfo = await getStartServerInfo({ dir, dev: isDev }) const startServerInfo = await getStartServerInfo({ dir, dev: isDev })
envInfo = startServerInfo.envInfo envInfo = startServerInfo.envInfo
cacheComponents = startServerInfo.cacheComponents
experimentalFeatures = startServerInfo.experimentalFeatures experimentalFeatures = startServerInfo.experimentalFeatures
} }
logStartInfo({ logStartInfo({
...@@ -378,6 +380,7 @@ export async function startServer( ...@@ -378,6 +380,7 @@ export async function startServer(
appUrl, appUrl,
envInfo, envInfo,
experimentalFeatures, experimentalFeatures,
cacheComponents,
logBundler: isDev, logBundler: isDev,
}) })
......
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <p>Hello, World!</p>
}
import { nextTestSetup } from 'e2e-utils'
const { version: nextVersion } = require('next/package.json')
const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true'
describe('dev-output', () => {
const { next, isTurbopack } = nextTestSetup({
files: __dirname,
})
it('shows Cache Components indicator when enabled', async () => {
const preamble = getPreambleOutput(next.cliOutput)
if (cacheComponentsEnabled) {
if (isTurbopack) {
expect(preamble).toContain('Next.js')
expect(preamble).toContain('Turbopack')
expect(preamble).toContain('Cache Components')
} else {
expect(preamble).toContain('Next.js')
expect(preamble).toContain('webpack')
expect(preamble).toContain('Cache Components')
}
} else {
// When cache components env is not set, should not show the indicator
expect(preamble).toContain('Next.js')
if (isTurbopack) {
expect(preamble).toContain('Turbopack')
} else {
expect(preamble).toContain('webpack')
}
expect(preamble).not.toContain('Cache Components')
}
})
})
function getPreambleOutput(cliOutput: string): string {
const lines: string[] = []
for (const line of cliOutput.split('\n')) {
// Capture lines up to and including the "Local:" line
lines.push(line.replace(nextVersion, 'x.y.z'))
if (line.includes('Local:')) {
break
}
}
return lines.join('\n').trim()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment