Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9c6b166

Browse files
committedFeb 3, 2025·
vite 6 support
1 parent a2d9960 commit 9c6b166

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed
 

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "react-router-devtools",
33
"description": "Devtools for React Router - debug, trace, find hydration errors, catch bugs and inspect server/client data with react-router-devtools",
44
"author": "Alem Tuzlak",
5-
"version": "1.1.0",
5+
"version": "1.1.1",
66
"license": "MIT",
77
"keywords": [
88
"react-router",
@@ -106,7 +106,7 @@
106106
"react": ">=17",
107107
"react-dom": ">=17",
108108
"react-router": ">=7.0.0",
109-
"vite": ">=5.0.0"
109+
"vite": ">=5.0.0 || >=6.0.0"
110110
},
111111
"devDependencies": {
112112
"@biomejs/biome": "1.9.4",

‎src/vite/plugin.tsx

+5-8
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,17 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
141141
server.httpServer?.on("listening", () => {
142142
process.rdt_port = server.config.server.port ?? 5173
143143
})
144-
// @ts-ignore - Fix this
145-
const channel = server.hot.channels.find((channel) => channel.name === "ws")
144+
//@ts-ignore - vite 5/6 compat
145+
const channel = server.hot.channels.find((channel) => channel.name === "ws") ?? server.environments?.client.hot
146+
146147
server.middlewares.use((req, res, next) =>
147148
handleDevToolsViteRequest(req, res, next, (parsedData) => {
148149
const { type, data, routine } = parsedData
149150
if (routine === "request-event") {
150151
unusedEvents.set(parsedData.id + parsedData.startTime, parsedData)
151152
for (const client of server.hot.channels) {
152153
// @ts-ignore - Fix this
153-
if (client.name === "ws") {
154-
client.send("request-event", JSON.stringify(parsedData))
155-
}
154+
client.send("request-event", JSON.stringify(parsedData))
156155
}
157156

158157
return
@@ -176,9 +175,7 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
176175
}
177176
for (const client of server.hot.channels) {
178177
// @ts-ignore - Fix this
179-
if (client.name === "ws") {
180-
client.send("route-info", JSON.stringify({ type, data }))
181-
}
178+
client.send("route-info", JSON.stringify({ type, data }))
182179
}
183180
})
184181
)

0 commit comments

Comments
 (0)
Please sign in to comment.