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 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
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)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was that? thanks much @ijjk I never though that the problem was that, I was searching for something in webpack config file all this time but without success

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah seems we were ignoring the src directory incorrectly for this case here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I dont understand, why it worked with the empty pages folder inside the src folder then, it is related?

)
},
}))
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