Skip to content

Commit 7336e83

Browse files
authored
[cache components]: show cache components enabled in DevTools (#85048)
Similar to how in DevTools we show if Turbopack is enabled, this shows that Cache Components is enabled. In the future, we might have a similar CTA to suggest enabling the feature. For now it only shows if it's actually enabled.
1 parent c9b464f commit 7336e83

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

packages/next/src/next-devtools/dev-overlay/menu/panel-router.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ const MenuPanel = () => {
9292
value: <ChevronRight />,
9393
onClick: () => setPanel('turbo-info'),
9494
},
95+
!!process.env.__NEXT_CACHE_COMPONENTS && {
96+
title: 'Cache Components is enabled.',
97+
label: 'Cache Components',
98+
value: 'Enabled',
99+
},
95100
isAppRouter && {
96101
label: 'Route Info',
97102
value: <ChevronRight />,

test/development/client-dev-overlay/index.test.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,64 @@ describe('client-dev-overlay', () => {
156156
}
157157
})
158158
})
159+
160+
describe('client-dev-overlay with Cache Components', () => {
161+
const { next, isTurbopack } = nextTestSetup({
162+
files: {
163+
pages: new FileRef(join(__dirname, 'pages')),
164+
'next.config.js': `
165+
module.exports = {
166+
cacheComponents: true,
167+
}
168+
`,
169+
},
170+
env: {
171+
__NEXT_DEV_INDICATOR_COOLDOWN_MS: '0',
172+
},
173+
})
174+
175+
it('should show Cache Components as enabled in the devtools menu', async () => {
176+
const browser = await next.browser('/')
177+
178+
const devToolsIndicator = await assertHasDevToolsIndicator(browser)
179+
try {
180+
await devToolsIndicator.click()
181+
} catch (cause) {
182+
const error = new Error('No DevTools Indicator to open.', { cause })
183+
throw error
184+
}
185+
186+
const devtoolsMenu = await browser.elementByCss('#nextjs-dev-tools-menu')
187+
const menuText = await devtoolsMenu.innerText()
188+
189+
// Should include Cache Components
190+
expect(menuText).toContain('Cache Components')
191+
expect(menuText).toContain('Enabled')
192+
193+
// Should also include Turbopack info
194+
if (isTurbopack) {
195+
expect(menuText).toMatchInlineSnapshot(`
196+
"Issues
197+
1
198+
Route
199+
Static
200+
Turbopack
201+
Enabled
202+
Cache Components
203+
Enabled
204+
Preferences"
205+
`)
206+
} else {
207+
expect(menuText).toMatchInlineSnapshot(`
208+
"Issues
209+
1
210+
Route
211+
Static
212+
Try Turbopack
213+
Cache Components
214+
Enabled
215+
Preferences"
216+
`)
217+
}
218+
})
219+
})

0 commit comments

Comments
 (0)