Skip to content

Commit

Permalink
vite 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Feb 3, 2025
1 parent a2d9960 commit 9c6b166
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-router-devtools",
"description": "Devtools for React Router - debug, trace, find hydration errors, catch bugs and inspect server/client data with react-router-devtools",
"author": "Alem Tuzlak",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",
"keywords": [
"react-router",
Expand Down Expand Up @@ -106,7 +106,7 @@
"react": ">=17",
"react-dom": ">=17",
"react-router": ">=7.0.0",
"vite": ">=5.0.0"
"vite": ">=5.0.0 || >=6.0.0"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
Expand Down
13 changes: 5 additions & 8 deletions src/vite/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,17 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
server.httpServer?.on("listening", () => {
process.rdt_port = server.config.server.port ?? 5173
})
// @ts-ignore - Fix this
const channel = server.hot.channels.find((channel) => channel.name === "ws")
//@ts-ignore - vite 5/6 compat
const channel = server.hot.channels.find((channel) => channel.name === "ws") ?? server.environments?.client.hot

server.middlewares.use((req, res, next) =>
handleDevToolsViteRequest(req, res, next, (parsedData) => {
const { type, data, routine } = parsedData
if (routine === "request-event") {
unusedEvents.set(parsedData.id + parsedData.startTime, parsedData)
for (const client of server.hot.channels) {
// @ts-ignore - Fix this
if (client.name === "ws") {
client.send("request-event", JSON.stringify(parsedData))
}
client.send("request-event", JSON.stringify(parsedData))
}

return
Expand All @@ -176,9 +175,7 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
}
for (const client of server.hot.channels) {
// @ts-ignore - Fix this
if (client.name === "ws") {
client.send("route-info", JSON.stringify({ type, data }))
}
client.send("route-info", JSON.stringify({ type, data }))
}
})
)
Expand Down

0 comments on commit 9c6b166

Please sign in to comment.