Skip to content

Commit

Permalink
Fix require-hook with just pages on deploy (#49274)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed May 5, 2023
1 parent 25a9547 commit 618dc2e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/next/src/build/index.ts
Expand Up @@ -283,8 +283,12 @@ export default async function build(

const publicDir = path.join(dir, 'public')
const isAppDirEnabled = !!config.experimental.appDir
const { pagesDir, appDir } = findPagesDir(dir, isAppDirEnabled)
NextBuildContext.pagesDir = pagesDir
NextBuildContext.appDir = appDir
hasAppDir = Boolean(appDir)

if (isAppDirEnabled) {
if (isAppDirEnabled && hasAppDir) {
if (!process.env.__NEXT_TEST_MODE && ciEnvironment.hasNextSupport) {
const requireHook = require.resolve('../server/require-hook')
const contents = await promises.readFile(requireHook, 'utf8')
Expand All @@ -297,11 +301,6 @@ export default async function build(
}
}

const { pagesDir, appDir } = findPagesDir(dir, isAppDirEnabled)
NextBuildContext.pagesDir = pagesDir
NextBuildContext.appDir = appDir
hasAppDir = Boolean(appDir)

const isSrcDir = path
.relative(dir, pagesDir || appDir || '')
.startsWith('src')
Expand Down

0 comments on commit 618dc2e

Please sign in to comment.