Skip to content

Commit

Permalink
rsc: mark next head as client component (#36138)
Browse files Browse the repository at this point in the history
Follow up of #36135 

Add `next/head` as client component
  • Loading branch information
huozhi committed Apr 13, 2022
1 parent a5103d2 commit 953cd9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/build/webpack/loaders/utils.ts
@@ -1,6 +1,6 @@
const defaultJsFileExtensions = ['js', 'mjs', 'jsx', 'ts', 'tsx', 'json']
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(
`[\\\\/]next[\\\\/](${nextClientComponents.join('|')})\\.js$`
Expand Down
@@ -1,12 +1,16 @@
import Nav from '../components/nav'
import Script from 'next/script'
import Head from 'next/head'

const envVar = process.env.ENV_VAR_TEST
const headerKey = 'x-next-test-client'

export default function Index({ header }) {
return (
<div>
<Head>
<meta name="rsc-title" content="index" />
</Head>
<h1>{`component:index.server`}</h1>
<div>{'env:' + envVar}</div>
<div>{'header:' + header}</div>
Expand Down
Expand Up @@ -18,6 +18,7 @@ export default function (context, { runtime, env }) {
const scriptTagContent = await browser.elementById('client-script').text()
// should have only 1 DOCTYPE
expect(homeHTML).toMatch(/^<!DOCTYPE html><html/)
expect(homeHTML).toMatch('<meta name="rsc-title" content="index"/>')
expect(homeHTML).toContain('component:index.server')
expect(homeHTML).toContain('env:env_var_test')
expect(homeHTML).toContain('header:test-util')
Expand Down

0 comments on commit 953cd9a

Please sign in to comment.