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(41456): check src/app folder too in getHasAppDir #41458

Merged
merged 6 commits into from Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion packages/next/lib/find-pages-dir.ts
Expand Up @@ -10,7 +10,7 @@ export const existsSync = (f: string): boolean => {
}
}

function findDir(dir: string, name: 'pages' | 'app'): string | null {
export function findDir(dir: string, name: 'pages' | 'app'): string | null {
// prioritize ./${name} over ./src/${name}
let curDir = path.join(dir, name)
if (existsSync(curDir)) return curDir
Expand Down
11 changes: 2 additions & 9 deletions packages/next/server/next-server.ts
Expand Up @@ -48,6 +48,7 @@ import {
FONT_LOADER_MANIFEST,
} from '../shared/lib/constants'
import { recursiveReadDirSync } from './lib/recursive-readdir-sync'
import { findDir } from '../lib/find-pages-dir'
import { format as formatUrl, UrlWithParsedQuery } from 'url'
import compression from 'next/dist/compiled/compression'
import { getPathMatch } from '../shared/lib/router/utils/path-match'
Expand Down Expand Up @@ -474,15 +475,7 @@ export default class NextNodeServer extends BaseServer {
}

protected getHasAppDir(dev: boolean): boolean {
const appDirectory = dev
? join(this.dir, 'app')
: join(this.serverDistDir, 'app')

try {
return fs.statSync(appDirectory).isDirectory()
} catch (err) {
return false
}
return Boolean(findDir(dev ? this.dir : this.serverDistDir, 'app'))
}

protected generateStaticRoutes(): Route[] {
Expand Down