Ensure clear distinction and proper handling between different rendering modes (SSR, SSG, SPA) with appropriate conditional logic for each mode’s specific requirements.

Different rendering modes have distinct behaviors and asset generation needs:

Apply mode-specific logic consistently:

function isSpaModeEnabled(reactRouterConfig) {
  // SPA Mode means we will only prerender a *single* `index.html` file
  // which prerenders only to the root route and can hydrate for _any_ path
  return (
    reactRouterConfig.ssr === false &&
    (reactRouterConfig.prerender == null || reactRouterConfig.prerender === false)
  );
}

// Conditionally remove exports based on rendering mode
if (!options?.ssr) {
  removeExports(ast, SERVER_ONLY_ROUTE_EXPORTS);
}

// Generate appropriate assets per mode
if (hasLoaders && isPrerenderingEnabled(reactRouterConfig)) {
  await prerenderData(handler, path, clientBuildDirectory);
}

This prevents configuration conflicts and ensures each mode generates the correct assets and applies the appropriate optimizations.