fix: declare vite-node as a dependency + support React Router 8 / Vite 8 (#261)#262
Merged
Merged
Conversation
…ite 8 (#261) The Vite plugin imports `vite-node` at runtime (it is marked `external` in tsup, so it stays a bare import in the published `dist`), but `vite-node` was only a devDependency. It resolved on React Router 7 purely as a phantom dependency of `@react-router/dev@7`, which declared `vite-node` itself. React Router 8 dropped `vite-node` from its dependencies, so resolution broke with `Cannot find package 'vite-node'`. - Move `vite-node` to `dependencies` (`^5.0.0 || ^6.0.0`, covering Vite 7 and 8). - Tidy the `vite` peer range to `>=5.0.0` (the `react-router` `>=7.0.0` peer already admits v8). - Add a minimal React Router 8 + Vite 8 example (`test-apps/react-router-v8-vite`) that wires the devtools plugin in by package name to exercise real consumer resolution. Verified: dev server boots cleanly, build and typecheck pass. - Align react/react-dom across the examples and docs to ^19.2.7 (RR8 floor) and pin react/react-dom via root pnpm.overrides so the shared, workspace-linked devtools package resolves a single React version (avoids an invalid-hook-call from a react/react-dom mismatch). - Ignore the intentionally-divergent v8 example in the sherif dependency check.
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #261 —
react-router-devtoolsfailed withError [ERR_MODULE_NOT_FOUND]: Cannot find package ''vite-node''after upgrading a project to React Router 8.Root cause
The Vite plugin imports
vite-nodeat runtime (src/vite/node-server.ts) to executereact-router.config.tsand route files.vite-nodeis markedexternalintsup.config.ts, so it stays a bareimport vite-node/...in the publisheddist/index.js— it must be resolvable at the consumer. But it was declared only as adevDependency.It worked on React Router 7 purely as a phantom dependency:
@react-router/dev@7declaresvite-nodeas a real dependency, which pnpm hoisted so the devtools could resolve it.@react-router/dev@8removedvite-nodefrom its dependencies, so the phantom dependency disappeared and resolution broke for any project on RR8.Changes
vite-nodetodependencieswith range^5.0.0 || ^6.0.0(vite-node@5→ Vite 7,vite-node@6→ Vite 8). This is the actual fix — it remainsexternalin tsup (correct; it resolves at the consumer).vitepeer range to>=5.0.0(was>=5.0.0 || >=6.0.0). Thereact-router>=7.0.0peer range already admits v8; both floors now explicitly cover React Router 8 + Vite 8.test-apps/react-router-v8-vite/— a minimal RR8 + Vite 8 framework-mode app that wires the devtools plugin in by package name (not a relativedist/path) so it exercises the real consumer resolution path, including thevite-nodedependency.react >=19.2.7, and the workspace shares one linkedreact-router-devtoolsacross all examples. Without a single React version, the devtools'' React subtree (TanStackDevtools) hit an Invalid hook call from a react/react-dom mismatch. Alignedreact/react-dom/@types/*to^19.2.7/^19.2.2across the examples + docs and pinnedreact/react-domvia rootpnpm.overrides.-p react-router-v8-vite) so the RR7-vs-RR8 / Vite7-vs-Vite8 divergence doesn''t trip the dependency check.Verification
react-router devboots with novite-nodeerror, page renders (HTTP 200), devtools instrumentation active;buildandtypecheckpass.react-router-vite,custom-server) still build & typecheck.react-router-devtoolspackage: typecheck clean, 377 unit tests pass.sherifandbiomeclean.Notes
vite-nodedependency move + peer range; thepnpm.overridesand example version bumps are monorepo-dev concerns only (rootpackage.jsonis private).vite-node@5, so the v8 example runsvite-node@5''s server against a Vite 8 dev server — verified working. A real single-version RR8 consumer would resolvevite-node@6.