Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix require-hook with just pages on deploy #49274

Merged
merged 2 commits into from May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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