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

Code before:
  return [
    {
      name: "react-router",
      config: async (_viteUserConfig, _viteConfigEnv) => {
        // Preload Vite's ESM build up-front as soon as we're in an async context
        await preloadViteEsm();

        // Ensure sync import of Vite works after async preload
        let vite = importViteEsmSync();

        viteUserConfig = _viteUserConfig;
        viteConfigEnv = _viteConfigEnv;
        viteCommand = viteConfigEnv.command;

        let viteClientConditions: string[] =
          viteUserConfig.resolve?.conditions ??
          "defaultClientConditions" in vite
            ? Array.from(vite.defaultClientConditions)
            : [];
        let viteServerConditions: string[] =
          viteUserConfig.ssr?.resolve?.conditions ??
          "defaultServerConditions" in vite
            ? Array.from(vite.defaultServerConditions)
            : [];

        logger = vite.createLogger(viteUserConfig.logLevel, {
          prefix: "[react-router]",
        });

        rootDirectory =
          viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();

        if (viteCommand === "serve") {
          typegenWatcherPromise = Typegen.watch(rootDirectory, {
            // ignore `info` logs from typegen since they are redundant when Vite plugin logs are active
            logger: vite.createLogger("warn", { prefix: "[react-router]" }),
          });
        }

        reactRouterConfigLoader = await createConfigLoader({
          rootDirectory,
          watch: viteCommand === "serve",
        });

        await updatePluginContext();

        Object.assign(
          process.env,
          vite.loadEnv(
            viteConfigEnv.mode,
            ctx.rootDirectory,

Review comment (suggestion):
We could make this more type safe by specifying the literal types accepted here.

```js
type DevProdCondition = 'development' | 'production';
type BaseCondition = 'module' | DevProdCondition;

type ClientCondition = BaseCondition | 'browser';
type ServerCondition = BaseCondition | 'node' | 'workerd' | 'worker';
```

You could then use this as `ClientCondition[]` or `ServerCondition[]`.

Reading the vite docs and seeing what we have here, I think this should be fine, also helps make sure we don't mistype anything. 

Code after:
  return [
    {
      name: "react-router",
      config: async (_viteUserConfig, _viteConfigEnv) => {
        // Preload Vite's ESM build up-front as soon as we're in an async context
        await preloadVite();

        // Ensure sync import of Vite works after async preload
        let vite = getVite();

        viteUserConfig = _viteUserConfig;
        viteConfigEnv = _viteConfigEnv;
        viteCommand = viteConfigEnv.command;

        // This is a compatibility layer for Vite 5. Default conditions were
        // automatically added to any custom conditions in Vite 5, but Vite 6
        // removed this behavior. Instead, the default conditions are overridden
        // by any custom conditions. If we wish to retain the default
        // conditions, we need to manually merge them using the provided default
        // conditions arrays exported from Vite. In Vite 5, these default
        // conditions arrays do not exist.
        // https://vite.dev/guide/migration.html#default-value-for-resolve-conditions
        let viteClientConditions: string[] = [
          ...(vite.defaultClientConditions ?? []),
        ];
        let viteServerConditions: string[] = [
          ...(vite.defaultServerConditions ?? []),
        ];

        logger = vite.createLogger(viteUserConfig.logLevel, {
          prefix: "[react-router]",
        });

        rootDirectory =
          viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();

        if (viteCommand === "serve") {
          typegenWatcherPromise = Typegen.watch(rootDirectory, {
            // ignore `info` logs from typegen since they are redundant when Vite plugin logs are active
            logger: vite.createLogger("warn", { prefix: "[react-router]" }),
          });
        }

        reactRouterConfigLoader = await createConfigLoader({
          rootDirectory,
          watch: viteCommand === "serve",
        });

        await updatePluginContext();

        Object.assign(