Skip to content

Commit

Permalink
Enable default functional document when concurrentFeatures is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Nov 30, 2021
1 parent 6e6bd21 commit 9fa2f30
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
13 changes: 10 additions & 3 deletions packages/next/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ export type PagesMapping = {
export function createPagesMapping(
pagePaths: string[],
extensions: string[],
isDev: boolean,
hasServerComponents: boolean
{
isDev,
hasServerComponents,
hasConcurrentFeatures,
}: {
isDev: boolean
hasServerComponents: boolean
hasConcurrentFeatures: boolean
}
): PagesMapping {
const previousPages: PagesMapping = {}
const pages: PagesMapping = pagePaths.reduce(
Expand Down Expand Up @@ -65,7 +72,7 @@ export function createPagesMapping(
// we alias these in development and allow webpack to
// allow falling back to the correct source file so
// that HMR can work properly when a file is added/removed
const documentPage = `_document${hasServerComponents ? '-web' : ''}`
const documentPage = `_document${hasConcurrentFeatures ? '-web' : ''}`
if (isDev) {
pages['/_app'] = `${PAGES_DIR_ALIAS}/_app`
pages['/_error'] = `${PAGES_DIR_ALIAS}/_error`
Expand Down
11 changes: 5 additions & 6 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,11 @@ export default async function build(
const mappedPages = nextBuildSpan
.traceChild('create-pages-mapping')
.traceFn(() =>
createPagesMapping(
pagePaths,
config.pageExtensions,
false,
hasServerComponents
)
createPagesMapping(pagePaths, config.pageExtensions, {
isDev: false,
hasServerComponents,
hasConcurrentFeatures,
})
)

const entrypoints = nextBuildSpan
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export default async function getBaseWebpackConfig(
prev.push(path.join(pagesDir, `_document.${ext}`))
return prev
}, [] as string[]),
`next/dist/pages/_document${hasServerComponents ? '-web' : ''}.js`,
`next/dist/pages/_document${webServerRuntime ? '-web' : ''}.js`,
]
}

Expand Down
7 changes: 5 additions & 2 deletions packages/next/server/dev/hot-reloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,11 @@ export default class HotReloader {
createPagesMapping(
pagePaths.filter((i) => i !== null) as string[],
this.config.pageExtensions,
true,
this.hasServerComponents
{
isDev: true,
hasConcurrentFeatures: this.webServerRuntime,
hasServerComponents: this.hasServerComponents,
}
)
)

Expand Down
13 changes: 0 additions & 13 deletions test/integration/react-18/app/pages/_document.js

This file was deleted.

0 comments on commit 9fa2f30

Please sign in to comment.