Skip to content

Commit

Permalink
Update renderOpts.dev handling and fix check (vercel#36666)
Browse files Browse the repository at this point in the history
* Update renderOpts.dev handling and fix check

* Update awaiting in load-components

* extra arg

* fix streaming case
  • Loading branch information
ijjk authored May 5, 2022
1 parent 08ffbc9 commit 41c0a66
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function getRender({
}

const server = new WebServer({
dev,
conf: config,
minimalMode: true,
webServerConfig: {
Expand Down
16 changes: 12 additions & 4 deletions packages/next/server/load-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,19 @@ export async function loadComponents(
}

const [DocumentMod, AppMod, ComponentMod, AppServerMod] = await Promise.all([
requirePage('/_document', distDir, serverless, rootEnabled),
requirePage('/_app', distDir, serverless, rootEnabled),
requirePage(pathname, distDir, serverless, rootEnabled),
Promise.resolve().then(() =>
requirePage('/_document', distDir, serverless, rootEnabled)
),
Promise.resolve().then(() =>
requirePage('/_app', distDir, serverless, rootEnabled)
),
Promise.resolve().then(() =>
requirePage(pathname, distDir, serverless, rootEnabled)
),
serverComponents
? requirePage('/_app.server', distDir, serverless, rootEnabled)
? Promise.resolve().then(() =>
requirePage('/_app.server', distDir, serverless, rootEnabled)
)
: null,
])

Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default class NextNodeServer extends BaseServer {
)
}

if (!this.renderOpts.dev) {
if (!options.dev) {
// pre-warm _document and _app as these will be
// needed for most requests
loadComponents(this.distDir, '/_document', this._isLikeServerless).catch(
Expand Down

0 comments on commit 41c0a66

Please sign in to comment.