Unverified Commit b04cdc9f authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix next/head in _app in RSC pages (#37928)

* fix next/head in _app with rsc

* revert change
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent 1a0346e6
......@@ -1280,6 +1280,11 @@ export default async function getBaseWebpackConfig(
loader: 'next-flight-client-loader',
},
},
// _app should be treated as a client component as well as all its dependencies.
{
test: new RegExp(`_app\\.(${rawPageExtensions.join('|')})$`),
layer: 'sc_client',
},
]
: []
: []),
......
......@@ -9,6 +9,7 @@ export default function (context) {
)
expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`)
})
it('should include global styles with `serverComponents: true`', async () => {
const browser = await webdriver(context.appPort, '/global-styles-rsc')
const currentColor = await browser.eval(
......@@ -24,4 +25,10 @@ export default function (context) {
)
expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`)
})
it('should support next/head inside _app with RSC', async () => {
const browser = await webdriver(context.appPort, '/multi')
const title = await browser.eval(`document.title`)
expect(title).toBe('hi')
})
}
......@@ -24,11 +24,17 @@ import streaming from './streaming'
import basic from './basic'
import { getNodeBuiltinModuleNotSupportedInEdgeRuntimeMessage } from 'next/dist/build/utils'
const appWithGlobalCss = `
const appWithGlobalCssAndHead = `
import '../styles.css'
import Head from 'next/head'
function App({ Component, pageProps }) {
return <Component {...pageProps} />
return <>
<Head>
<title>hi</title>
</Head>
<Component {...pageProps} />
</>
}
export default App
......@@ -156,7 +162,7 @@ const nodejsRuntimeBasicSuite = {
const cssSuite = {
runTests: css,
beforeAll: () => appPage.write(appWithGlobalCss),
beforeAll: () => appPage.write(appWithGlobalCssAndHead),
afterAll: () => appPage.delete(),
}
......
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