mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-11-06 09:03:47 +08:00
fix(extraction): a file-based router reads only its own app in a monorepo (#2129)
create-t3-turbo, tamagui's starter and react-native-reusables keep an Expo app beside a Next.js app. Expo Router read the Next app's `app/` folder as its own, so `layout.tsx` became a `/layout` screen, `page.tsx` a `/page` one, `_components/posts.tsx` and `api/auth/[...all]/route.ts` screens too, and a shared `packages/app/` library's files became screens as well. A resolver can now name `appDependencies`; its extractor runs on a file only when that file's package.json or an enclosing one declares one of them. When no manifest in the project declares any, detection found the framework by other evidence and it runs everywhere, as before. Expo Router names `expo-router`, Next.js `next`. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1ef1eb886c
commit
92e14eda40
@@ -713,6 +713,7 @@ function scoreMatch(href: string[], route: string[]): number | null {
|
||||
export const expoRouterResolver: FrameworkResolver = {
|
||||
name: 'expo-router',
|
||||
languages: [...ROUTE_LANGUAGES],
|
||||
appDependencies: ['expo-router'],
|
||||
|
||||
detect(context: ResolutionContext): boolean {
|
||||
if (dependsOn(context, 'expo-router')) return true;
|
||||
|
||||
@@ -222,6 +222,7 @@ export function nextNavVerb(name: string): string | null {
|
||||
export const nextjsResolver: FrameworkResolver = {
|
||||
name: 'nextjs',
|
||||
languages: [...ROUTE_LANGUAGES],
|
||||
appDependencies: ['next'],
|
||||
|
||||
detect(context: ResolutionContext): boolean {
|
||||
if (dependsOn(context, 'next')) return true;
|
||||
|
||||
@@ -239,6 +239,16 @@ export interface FrameworkResolver {
|
||||
name: string;
|
||||
/** Languages this framework applies to. If omitted, applies to all languages. */
|
||||
languages?: Language[];
|
||||
/**
|
||||
* Packages an app declares when it is built on this framework. When set,
|
||||
* `extract()` runs only on files of an app whose package.json — the file's
|
||||
* own or an enclosing one — declares one of them: in a monorepo with an Expo
|
||||
* app beside a Next.js app, Expo Router must not read the Next app's
|
||||
* `app/layout.tsx` as a `/layout` screen. When no manifest in the project
|
||||
* declares any, detection found the framework by other evidence and the
|
||||
* extractor runs on every file, as before.
|
||||
*/
|
||||
appDependencies?: readonly string[];
|
||||
/** Detect if project uses this framework (project-level, called once at startup) */
|
||||
detect(context: ResolutionContext): boolean;
|
||||
/** Resolve a reference using framework-specific patterns */
|
||||
|
||||
Reference in New Issue
Block a user