diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx
index 4f566eb83e3cb..badc0f7a6b85c 100644
--- a/packages/next/pages/_document.tsx
+++ b/packages/next/pages/_document.tsx
@@ -1,5 +1,8 @@
import React, { Component, ReactElement, ReactNode, useContext } from 'react'
-import { OPTIMIZED_FONT_PROVIDERS } from '../shared/lib/constants'
+import {
+ OPTIMIZED_FONT_PROVIDERS,
+ NEXT_BUILTIN_DOCUMENT,
+} from '../shared/lib/constants'
import type {
DocumentContext,
DocumentInitialProps,
@@ -310,7 +313,6 @@ export default class Document
extends Component {
// Add a special property to the built-in `Document` component so later we can
// identify if a user customized `Document` is used or not.
-export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'
const InternalFunctionDocument: DocumentType =
function InternalFunctionDocument() {
return (
diff --git a/packages/next/server/render.tsx b/packages/next/server/render.tsx
index fa2f974d6c957..da08e84459242 100644
--- a/packages/next/server/render.tsx
+++ b/packages/next/server/render.tsx
@@ -36,6 +36,7 @@ import {
UNSTABLE_REVALIDATE_RENAME_ERROR,
} from '../lib/constants'
import {
+ NEXT_BUILTIN_DOCUMENT,
SERVER_PROPS_ID,
STATIC_PROPS_ID,
STATIC_STATUS_PAGES,
@@ -81,7 +82,6 @@ import { FlushEffectsContext } from '../shared/lib/flush-effects'
import { interopDefault } from '../lib/interop-default'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import { urlQueryToSearchParams } from '../shared/lib/router/utils/querystring'
-import { NEXT_BUILTIN_DOCUMENT } from '../pages/_document'
let optimizeAmp: typeof import('./optimize-amp').default
let getFontDefinitionFromManifest: typeof import('./font-utils').getFontDefinitionFromManifest
diff --git a/packages/next/shared/lib/constants.ts b/packages/next/shared/lib/constants.ts
index bedca6446bb5e..7f3dc9acd9286 100644
--- a/packages/next/shared/lib/constants.ts
+++ b/packages/next/shared/lib/constants.ts
@@ -25,6 +25,7 @@ export const CLIENT_PUBLIC_FILES_PATH = 'public'
export const CLIENT_STATIC_FILES_PATH = 'static'
export const CLIENT_STATIC_FILES_RUNTIME = 'runtime'
export const STRING_LITERAL_DROP_BUNDLE = '__NEXT_DROP_CLIENT_FILE__'
+export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'
// server/middleware-flight-manifest.js
export const MIDDLEWARE_FLIGHT_MANIFEST = 'middleware-flight-manifest'
diff --git a/test/e2e/styled-jsx/index.test.ts b/test/e2e/styled-jsx/index.test.ts
index c0f74057fbf36..189a37c79785e 100644
--- a/test/e2e/styled-jsx/index.test.ts
+++ b/test/e2e/styled-jsx/index.test.ts
@@ -14,21 +14,7 @@ function runTest(packageManager?: string) {
next = await createNext({
files: {
pages: new FileRef(path.join(appDir, 'pages')),
- // 'next.config.js': new FileRef(path.join(appDir, 'next.config.js')),
},
-
- // files: {
- // 'pages/index.js': `
- // export default function Page() {
- // return (
- //
- //
- //
hello world
- //
- // )
- // }
- // `,
- // },
...(packageManager
? {
installCommand: `npx ${packageManager} install`,
@@ -41,8 +27,8 @@ function runTest(packageManager?: string) {
it('should contain styled-jsx styles in html', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
- const body = $('body').text()
- expect(body).toMatch(/color:(\s)*red/)
+ const isReact17 = process.env.NEXT_TEST_REACT_VERSION === '^17'
+ expect($(isReact17 ? 'head' : 'body').text()).toMatch(/color:(\s)*red/)
})
})
}