Unverified Commit f5cb7bd8 authored by Alexander Sviridov's avatar Alexander Sviridov Committed by GitHub

fix(41456): check src/app folder too in getHasAppDir (#41458)

fixes https://github.com/vercel/next.js/issues/41456

When we check if app folder exists, check for src/app path too

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Co-authored-by: 's avatarJiachi Liu <inbox@huozhi.im>
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 6249307b
......@@ -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
......
......@@ -305,7 +305,9 @@ export default class DevServer extends Server {
ignored: (pathname: string) => {
return (
!files.some((file) => file.startsWith(pathname)) &&
!directories.some((dir) => pathname.startsWith(dir))
!directories.some(
(dir) => pathname.startsWith(dir) || dir.startsWith(pathname)
)
)
},
}))
......
......@@ -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'
......@@ -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[] {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment