Repository: remix-run/react-router
File: packages/react-router-dev/vite/plugin.ts (TypeScript)

Code before:
        } satisfies Vite.BuildOptions["rollupOptions"];

        return {
          __reactRouterPluginContext: ctx,
          appType:
            viteCommand === "serve" &&
            viteConfigEnv.mode === "production" &&
            ctx.reactRouterConfig.ssr === false
              ? "spa"
              : "custom",

          ssr: {
            external: ssrExternals,
            resolve: {
              conditions:
                viteCommand === "build"
                  ? viteServerConditions
                  : ["development", ...viteServerConditions],
              externalConditions:
                viteCommand === "build"
                  ? viteServerConditions
                  : ["development", ...viteServerConditions],
            },
          },
          optimizeDeps: {
            entries: ctx.reactRouterConfig.future.unstable_optimizeDeps
              ? [
                  ctx.entryClientFilePath,
                  ...Object.values(ctx.reactRouterConfig.routes).map((route) =>
                    path.join(ctx.reactRouterConfig.appDirectory, route.file)
                  ),
                ]
              : [],
            include: [
              // Pre-bundle React dependencies to avoid React duplicates,
              // even if React dependencies are not direct dependencies.
              // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
              "react",
              "react/jsx-runtime",
              "react/jsx-dev-runtime",
              "react-dom",
              "react-dom/client",

              // Pre-bundle router dependencies to avoid router duplicates.
              // Mismatching routers cause `Error: You must render this element inside a <Remix> element`.
              "react-router",
              "react-router/dom",
              // Check to avoid "Failed to resolve dependency: react-router-dom, present in 'optimizeDeps.include'"
              ...(hasDependency("react-router-dom")
                ? ["react-router-dom"]
                : []),

Review comment (suggestion):
I would add a comment and explain why we need this, and link to: https://vite.dev/guide/migration#default-value-for-resolve-conditions

Something like:

```
// Vite 6 no longer adds default conditions internally.
// We need to explicitly include them to ensure proper module resolution
// especially for packages that rely on specific conditions like @prisma/client
// see {link}
```

Maybe it's just me, but this code is quite critical as it handles module resolution, which is a critical part of how dependencies get loaded in the application

i would prefer being very clear here

Code after:
            } else {
              defaultHandler(warning);
            }
          },
        } satisfies Vite.BuildOptions["rollupOptions"];

        return {
          __reactRouterPluginContext: ctx,
          appType:
            viteCommand === "serve" &&
            viteConfigEnv.mode === "production" &&
            ctx.reactRouterConfig.ssr === false
              ? "spa"
              : "custom",

          ssr: {
            external: ssrExternals,
            resolve: {
              conditions:
                viteCommand === "build"
                  ? viteServerConditions
                  : ["development", ...viteServerConditions],
              externalConditions:
                viteCommand === "build"
                  ? viteServerConditions
                  : ["development", ...viteServerConditions],
            },
          },
          optimizeDeps: {
            entries: ctx.reactRouterConfig.future.unstable_optimizeDeps
              ? [
                  ctx.entryClientFilePath,
                  ...Object.values(ctx.reactRouterConfig.routes).map((route) =>
                    path.join(ctx.reactRouterConfig.appDirectory, route.file)
                  ),
                ]
              : [],
            include: [
              // Pre-bundle React dependencies to avoid React duplicates,
              // even if React dependencies are not direct dependencies.
              // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
              "react",
              "react/jsx-runtime",
              "react/jsx-dev-runtime",
              "react-dom",
              "react-dom/client",

              // Pre-bundle router dependencies to avoid router duplicates.
              // Mismatching routers cause `Error: You must render this element inside a <Remix> element`.
              "react-router",
              "react-router/dom",