@@ -83,6 +83,8 @@ type ServerBundlesBuildManifest = BaseBuildManifest & {
8383
8484type ServerModuleFormat = "esm" | "cjs" ;
8585
86+ type ValidateConfigFunction = ( config : ReactRouterConfig ) => string | void ;
87+
8688interface FutureConfig {
8789 /**
8890 * Enable route middleware
@@ -356,11 +358,13 @@ async function resolveConfig({
356358 viteNodeContext,
357359 reactRouterConfigFile,
358360 skipRoutes,
361+ validateConfig,
359362} : {
360363 root : string ;
361364 viteNodeContext : ViteNode . Context ;
362365 reactRouterConfigFile ?: string ;
363366 skipRoutes ?: boolean ;
367+ validateConfig ?: ValidateConfigFunction ;
364368} ) : Promise < Result < ResolvedReactRouterConfig > > {
365369 let reactRouterUserConfig : ReactRouterConfig = { } ;
366370
@@ -383,6 +387,13 @@ async function resolveConfig({
383387 }
384388
385389 reactRouterUserConfig = configModule . default ;
390+
391+ if ( validateConfig ) {
392+ const error = validateConfig ( reactRouterUserConfig ) ;
393+ if ( error ) {
394+ return err ( error ) ;
395+ }
396+ }
386397 } catch ( error ) {
387398 return err ( `Error loading ${ reactRouterConfigFile } : ${ error } ` ) ;
388399 }
@@ -631,11 +642,13 @@ export async function createConfigLoader({
631642 watch,
632643 mode,
633644 skipRoutes,
645+ validateConfig,
634646} : {
635647 watch : boolean ;
636648 rootDirectory ?: string ;
637649 mode : string ;
638650 skipRoutes ?: boolean ;
651+ validateConfig ?: ValidateConfigFunction ;
639652} ) : Promise < ConfigLoader > {
640653 root = Path . normalize ( root ?? process . env . REACT_ROUTER_ROOT ?? process . cwd ( ) ) ;
641654
@@ -660,7 +673,13 @@ export async function createConfigLoader({
660673 updateReactRouterConfigFile ( ) ;
661674
662675 let getConfig = ( ) =>
663- resolveConfig ( { root, viteNodeContext, reactRouterConfigFile, skipRoutes } ) ;
676+ resolveConfig ( {
677+ root,
678+ viteNodeContext,
679+ reactRouterConfigFile,
680+ skipRoutes,
681+ validateConfig,
682+ } ) ;
664683
665684 let appDirectory : string ;
666685
0 commit comments