Skip to content

Commit ce1c7a0

Browse files
committed
fix for custom ids
1 parent 783d160 commit ce1c7a0

File tree

9 files changed

+38
-11
lines changed

9 files changed

+38
-11
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
"npm-run-all": "^4.1.5",
133133
"postcss": "^8.5.1",
134134
"prompt": "^1.3.0",
135-
"tailwind-merge": "^3.0.1",
136135
"tailwindcss": "^3.4.0",
137136
"tailwindcss-animate": "^1.0.7",
138137
"tsup": "^8.3.6",
@@ -159,7 +158,8 @@
159158
"react-d3-tree": "^3.6.4",
160159
"react-diff-viewer-continued": "^4.0.5",
161160
"react-hotkeys-hook": "^4.6.1",
162-
"react-tooltip": "^5.28.0"
161+
"react-tooltip": "^5.28.0",
162+
"tailwind-merge": "^3.0.1"
163163
},
164164
"optionalDependencies": {
165165
"@biomejs/cli-darwin-arm64": "^1.9.4",

src/client/components/RouteInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const RouteInfo = ({ route: routeToUse, className, openNewRoute, onClose
4242
)}
4343
<div className="flex gap-2">
4444
<span className="whitespace-nowrap text-gray-500">Route file:</span>
45-
{route.id}
45+
{route.module ?? routeToUse.file}
4646
</div>
4747

4848
<div className="mb-4 mt-4 flex flex-col gap-2">

src/client/utils/routing.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,29 @@ const ROUTE_FILLS = {
4848
PURPLE: "fill-purple-500 text-white",
4949
} as const
5050

51+
const UNDISCOVERED_ROUTE_FILLS = {
52+
GREEN: "fill-green-500/20 text-white",
53+
BLUE: "fill-blue-500/20 text-white",
54+
PURPLE: "fill-purple-500/20 text-white",
55+
}
56+
5157
export function getRouteColor(route: Route) {
58+
const isDiscovered = !!window.__reactRouterManifest?.routes[route.id]
59+
const FILL = isDiscovered ? ROUTE_FILLS : UNDISCOVERED_ROUTE_FILLS
5260
switch (getRouteType(route)) {
5361
case "ROOT":
54-
return ROUTE_FILLS.PURPLE
55-
case "LAYOUT":
56-
return ROUTE_FILLS.BLUE
62+
return FILL.PURPLE
63+
5764
case "ROUTE":
58-
return ROUTE_FILLS.GREEN
65+
return FILL.GREEN
66+
67+
case "LAYOUT":
68+
return FILL.BLUE
5969
}
6070
}
6171
export type ExtendedRoute = EntryRoute & {
6272
url: string
73+
file?: string
6374
errorBoundary: { hasErrorBoundary: boolean; errorBoundaryId: string | null }
6475
}
6576

src/vite/node-server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { installSourcemapsSupport } from "vite-node/source-map"
55

66
// create vite server
77
const server = await createServer({
8+
mode: "development",
9+
root: process.cwd(),
810
server: {
911
preTransformRequests: false,
1012
hmr: false,

src/vite/plugin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
112112
...recursiveFlatten(
113113
routeOrRoutes.children.map((child) => ({
114114
...child,
115-
parentId: routeOrRoutes.id,
115+
parentId: routeOrRoutes.file.split(".").slice(0, -1).join("."),
116116
}))
117117
),
118118
]

test-apps/react-router-vite/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const loader = ({context, devTools }: LoaderFunctionArgs) => {
2828
});
2929
const start =devTools?.tracing.start("test")!;
3030
devTools?.tracing.end("test", start);
31-
return data({ message: "Hello World", mainPromise, bigInt: BigInt(10) }, { headers: { "Cache-Control": "max-age=3600, private" } });
31+
return data({ message: "Hello World", mainPromise, bigInt: BigInt(10) }, );
3232
}
3333

3434
export const action =async ({devTools}: ActionFunctionArgs) => {
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11

22
import { flatRoutes } from "@react-router/fs-routes";
3-
export default flatRoutes()
3+
import { type RouteConfig, index, layout, prefix, route } from "@react-router/dev/routes"
4+
import subroutes from "./subroutes.js"
5+
6+
7+
8+
export default [...await flatRoutes(), ...subroutes ]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { type RouteConfig, index, layout, prefix, route } from "@react-router/dev/routes"
2+
3+
4+
export default [
5+
route("outside", "./routes/_index.tsx", { id: "something" }),
6+
7+
] satisfies RouteConfig

test-apps/react-router-vite/vite.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export default defineConfig({
3636
reactRouter(),
3737
tsconfigPaths()
3838
],
39-
39+
optimizeDeps: {
40+
noDiscovery: true
41+
},
4042
server: {
4143
open: true,
4244
port: 3000,

0 commit comments

Comments
 (0)