Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/vite8-envfile-deprecation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"react-router-devtools": patch
---

Stop emitting the `envFile` deprecation warning on Vite 8.

The internal vite-node server passes `envFile: false` to `createServer`, which Vite 8 deprecated in favour of `envDir: false`. Every Vite 8 consumer therefore saw `The 'envFile' option is deprecated, please use 'envDir: false' instead.` on startup, because the warning is emitted from a top-level `createServer` call that no user config can reach. The key is now chosen from the installed Vite major, so Vite 8 gets `envDir: false` while the existing `>=5` peers keep `envFile: false`.
4 changes: 1 addition & 3 deletions packages/react-router-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
"default": "./dist/server.js"
}
},
"files": [
"dist"
],
"files": ["dist"],
"repository": {
"type": "git",
"url": "git+https://github.com/code-forge-io/react-router-devtools.git"
Expand Down
9 changes: 7 additions & 2 deletions packages/react-router-devtools/src/vite/node-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ViteNodeRunner } from "vite-node/client"
import { ViteNodeServer } from "vite-node/server"
import { installSourcemapsSupport } from "vite-node/source-map"

const viteMajor = Number(viteVersion.split(".")[0])

// create vite server
const server = await createServer({
mode: "development",
Expand All @@ -17,11 +19,14 @@ const server = await createServer({
noDiscovery: true,
},
configFile: false,
envFile: false,
// Vite 8 deprecated `envFile` in favour of `envDir: false` and warns when
// it is passed. Older peers (>=5) only understand `envFile`, so pick the
// key the installed Vite expects.
...(viteMajor >= 8 ? ({ envDir: false } as const) : ({ envFile: false } as const)),
plugins: [],
})
// For old Vite, this is need to initialize the plugins.
if (Number(viteVersion.split(".")[0]) < 6) {
if (viteMajor < 6) {
await server.pluginContainer.buildStart({})
}

Expand Down
Loading