Skip to content

Commit e72fc6e

Browse files
Remove resolved unstable_rootRoute config (#14319)
1 parent 0ee1d14 commit e72fc6e

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

integration/vite-presets-test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ test.describe("Vite / presets", async () => {
226226
"serverBundles",
227227
"serverModuleFormat",
228228
"ssr",
229-
"unstable_rootRouteFile",
230229
"unstable_routeConfig",
231230
]);
232231

packages/react-router-dev/config/config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,6 @@ export type ResolvedReactRouterConfig = Readonly<{
264264
* SPA without server-rendering. Default's to `true`.
265265
*/
266266
ssr: boolean;
267-
/**
268-
* The absolute path to the root route file.
269-
*/
270-
unstable_rootRouteFile: string;
271267
/**
272268
* The resolved array of route config entries exported from `routes.ts`
273269
*/
@@ -615,7 +611,6 @@ async function resolveConfig({
615611
serverBundles,
616612
serverModuleFormat,
617613
ssr,
618-
unstable_rootRouteFile: rootRouteFile,
619614
unstable_routeConfig: routeConfig,
620615
} satisfies ResolvedReactRouterConfig);
621616

packages/react-router-dev/vite/rsc/plugin.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type * as Vite from "vite";
22
import { init as initEsModuleLexer } from "es-module-lexer";
3+
import * as Path from "pathe";
34
import * as babel from "@babel/core";
45
import colors from "picocolors";
56

@@ -28,14 +29,23 @@ import { warnOnClientSourceMaps } from "../plugins/warn-on-client-source-maps";
2829

2930
export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
3031
let configLoader: ConfigLoader;
31-
let config: ResolvedReactRouterConfig;
3232
let typegenWatcherPromise: Promise<Typegen.Watcher> | undefined;
3333
let viteCommand: Vite.ConfigEnv["command"];
3434
let routeIdByFile: Map<string, string> | undefined;
3535
let logger: Vite.Logger;
3636

3737
const defaultEntries = getDefaultEntries();
3838

39+
let config: ResolvedReactRouterConfig;
40+
let rootRouteFile: string;
41+
function updateConfig(newConfig: ResolvedReactRouterConfig) {
42+
config = newConfig;
43+
rootRouteFile = Path.resolve(
44+
newConfig.appDirectory,
45+
newConfig.routes.root.file,
46+
);
47+
}
48+
3949
return [
4050
{
4151
name: "react-router/rsc",
@@ -75,7 +85,7 @@ export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
7585

7686
const configResult = await configLoader.getConfig();
7787
if (!configResult.ok) throw new Error(configResult.error);
78-
config = configResult.value;
88+
updateConfig(configResult.value);
7989

8090
if (
8191
viteUserConfig.base &&
@@ -246,7 +256,7 @@ export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
246256
});
247257

248258
// Update shared plugin config reference
249-
config = result.value;
259+
updateConfig(result.value);
250260

251261
if (configChanged || routeConfigChanged) {
252262
invalidateVirtualModules(viteDevServer);
@@ -315,7 +325,7 @@ export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
315325
id,
316326
viteCommand,
317327
routeIdByFile,
318-
rootRouteFile: config.unstable_rootRouteFile,
328+
rootRouteFile,
319329
viteEnvironment: this.environment,
320330
});
321331
},

0 commit comments

Comments
 (0)