Skip to content

Commit

Permalink
fix: fix the failure of App entry recognition (#5862)
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin committed Jun 21, 2024
1 parent ea16092 commit 8c71964
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/green-balloons-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/runtime': patch
---

fix: Fix the failure of App entry recognition when there are pages and routes paths.

fix: 修复当存在 pages 和 routes 路径时,App 入口识别失败
2 changes: 1 addition & 1 deletion packages/runtime/plugin-runtime/src/cli/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import { JS_EXTENSIONS, findExists } from '@modern-js/utils';
import { APP_FILE_NAME } from './constants';

const hasApp = (dir: string) =>
export const hasApp = (dir: string) =>
findExists(
JS_EXTENSIONS.map(ext => path.resolve(dir, `${APP_FILE_NAME}${ext}`)),
);
Expand Down
5 changes: 5 additions & 0 deletions packages/runtime/plugin-runtime/src/router/cli/entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path';
import { JS_EXTENSIONS, findExists, fs, isRouterV5 } from '@modern-js/utils';
import { Entrypoint } from '@modern-js/types';
import { hasApp } from '../../cli/entry';
import {
FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
NESTED_ROUTES_DIR,
Expand Down Expand Up @@ -31,6 +32,10 @@ export const modifyEntrypoints = (
if (!entrypoint.isAutoMount) {
return entrypoint;
}
const isHasApp = hasApp(entrypoint.absoluteEntryDir!);
if (isHasApp) {
return entrypoint;
}
const isHasNestedRoutes = hasNestedRoutes(entrypoint.absoluteEntryDir!);
const isHasPages = hasPages(entrypoint.absoluteEntryDir!);
if (!isHasNestedRoutes && !isHasPages) {
Expand Down

0 comments on commit 8c71964

Please sign in to comment.