Skip to content

Commit

Permalink
fix(41456): check src/app folder too in getHasAppDir (#41458)
Browse files Browse the repository at this point in the history
fixes #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: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
3 people committed Oct 17, 2022
1 parent 6249307 commit f5cb7bd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
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
4 changes: 3 additions & 1 deletion packages/next/server/dev/next-dev-server.ts
Expand Up @@ -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)
)
)
},
}))
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
File renamed without changes.

0 comments on commit f5cb7bd

Please sign in to comment.