@@ -22,8 +22,6 @@ import {
2222 configRoutesToRouteManifest ,
2323} from "./routes" ;
2424import { detectPackageManager } from "../cli/detectPackageManager" ;
25- import { importViteEsmSync } from "../vite/import-vite-esm-sync" ;
26- import { preloadViteEsm } from "../vite/import-vite-esm-sync" ;
2725
2826const excludedConfigPresetKeys = [ "presets" ] as const satisfies ReadonlyArray <
2927 keyof ReactRouterConfig
@@ -530,12 +528,15 @@ export async function createConfigLoader({
530528} ) : Promise < ConfigLoader > {
531529 root = Path . normalize ( root ?? process . env . REACT_ROUTER_ROOT ?? process . cwd ( ) ) ;
532530
531+ let vite = await import ( "vite" ) ;
533532 let viteNodeContext = await ViteNode . createContext ( {
534533 root,
535534 mode : watch ? "development" : "production" ,
536535 server : ! watch ? { watch : null } : { } ,
537536 ssr : { external : ssrExternals } ,
538- customLogger : await createCustomLogger ( ) ,
537+ customLogger : vite . createLogger ( "warn" , {
538+ prefix : "[react-router]" ,
539+ } ) ,
539540 } ) ;
540541
541542 let reactRouterConfigFile : string | undefined ;
@@ -584,9 +585,11 @@ export async function createConfigLoader({
584585 let dirname = Path . dirname ( path ) ;
585586
586587 return (
587- path !== root &&
588- dirname !== root &&
589- ! dirname . startsWith ( appDirectory )
588+ ! dirname . startsWith ( appDirectory ) &&
589+ // Ensure we're only watching files outside of the app directory
590+ // that are at the root level, not nested in subdirectories
591+ path !== root && // Watch the root directory itself
592+ dirname !== root // Watch files at the root level
590593 ) ;
591594 } ,
592595 } ) ;
@@ -804,27 +807,6 @@ function isInReactRouterMonorepo() {
804807 return serverRuntimeParentDir === "packages" ;
805808}
806809
807- async function createCustomLogger ( ) {
808- await preloadViteEsm ( ) ;
809- const vite = importViteEsmSync ( ) ;
810-
811- let customLogger = vite . createLogger ( undefined , {
812- prefix : "[react-router config]" ,
813- } ) ;
814-
815- // Patch the info method to filter out page reload messages that show up in
816- // the terminal when adding or removing the config file
817- let originalInfo = customLogger . info ;
818- customLogger . info = function ( msg , options ) {
819- if ( msg . includes ( "page reload" ) ) {
820- return ;
821- }
822- return originalInfo . call ( this , msg , options ) ;
823- } ;
824-
825- return customLogger ;
826- }
827-
828810function omitRoutes (
829811 config : ResolvedReactRouterConfig
830812) : ResolvedReactRouterConfig {
0 commit comments