Skip to content

Commit a82b977

Browse files
committed
simplify page check
1 parent 657dd55 commit a82b977

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

packages/nextjs/src/config/manifest/buildManifest.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function scanAppDirectory(dir: string, basePath: string = ''): RouteInfo[] {
8383

8484
try {
8585
const entries = fs.readdirSync(dir, { withFileTypes: true });
86-
const pageFile = getHighestPriorityPageFile(entries);
86+
const pageFile = entries.some(entry => isPageFile(entry.name));
8787

8888
if (pageFile) {
8989
const routePath = basePath || '/';
@@ -138,20 +138,6 @@ function scanAppDirectory(dir: string, basePath: string = ''): RouteInfo[] {
138138
return routes;
139139
}
140140

141-
function getHighestPriorityPageFile(entries: fs.Dirent[]): string | null {
142-
// Next.js precedence order: .tsx > .ts > .jsx > .js
143-
const pageFiles = entries.filter(entry => entry.isFile() && isPageFile(entry.name)).map(entry => entry.name);
144-
145-
if (pageFiles.length === 0) return null;
146-
147-
if (pageFiles.includes('page.tsx')) return 'page.tsx';
148-
if (pageFiles.includes('page.ts')) return 'page.ts';
149-
if (pageFiles.includes('page.jsx')) return 'page.jsx';
150-
if (pageFiles.includes('page.js')) return 'page.js';
151-
152-
return null;
153-
}
154-
155141
/**
156142
* Returns a route manifest for the given app directory
157143
*/

0 commit comments

Comments
 (0)