Unverified Commit 953cd9af authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

rsc: mark next head as client component (#36138)

Follow up of #36135 

Add `next/head` as client component
parent a5103d2e
const defaultJsFileExtensions = ['js', 'mjs', 'jsx', 'ts', 'tsx', 'json'] const defaultJsFileExtensions = ['js', 'mjs', 'jsx', 'ts', 'tsx', 'json']
const imageExtensions = ['jpg', 'jpeg', 'png', 'webp', 'avif'] const imageExtensions = ['jpg', 'jpeg', 'png', 'webp', 'avif']
const nextClientComponents = ['link', 'image', 'script'] const nextClientComponents = ['link', 'image', 'head', 'script']
const NEXT_BUILT_IN_CLIENT_RSC_REGEX = new RegExp( const NEXT_BUILT_IN_CLIENT_RSC_REGEX = new RegExp(
`[\\\\/]next[\\\\/](${nextClientComponents.join('|')})\\.js$` `[\\\\/]next[\\\\/](${nextClientComponents.join('|')})\\.js$`
......
import Nav from '../components/nav' import Nav from '../components/nav'
import Script from 'next/script' import Script from 'next/script'
import Head from 'next/head'
const envVar = process.env.ENV_VAR_TEST const envVar = process.env.ENV_VAR_TEST
const headerKey = 'x-next-test-client' const headerKey = 'x-next-test-client'
...@@ -7,6 +8,9 @@ const headerKey = 'x-next-test-client' ...@@ -7,6 +8,9 @@ const headerKey = 'x-next-test-client'
export default function Index({ header }) { export default function Index({ header }) {
return ( return (
<div> <div>
<Head>
<meta name="rsc-title" content="index" />
</Head>
<h1>{`component:index.server`}</h1> <h1>{`component:index.server`}</h1>
<div>{'env:' + envVar}</div> <div>{'env:' + envVar}</div>
<div>{'header:' + header}</div> <div>{'header:' + header}</div>
......
...@@ -18,6 +18,7 @@ export default function (context, { runtime, env }) { ...@@ -18,6 +18,7 @@ export default function (context, { runtime, env }) {
const scriptTagContent = await browser.elementById('client-script').text() const scriptTagContent = await browser.elementById('client-script').text()
// should have only 1 DOCTYPE // should have only 1 DOCTYPE
expect(homeHTML).toMatch(/^<!DOCTYPE html><html/) expect(homeHTML).toMatch(/^<!DOCTYPE html><html/)
expect(homeHTML).toMatch('<meta name="rsc-title" content="index"/>')
expect(homeHTML).toContain('component:index.server') expect(homeHTML).toContain('component:index.server')
expect(homeHTML).toContain('env:env_var_test') expect(homeHTML).toContain('env:env_var_test')
expect(homeHTML).toContain('header:test-util') expect(homeHTML).toContain('header:test-util')
......
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