Skip to content

Commit a816df1

Browse files
authored
fix: stop emitting the envFile deprecation warning on Vite 8 (#266)
The vite-node server passes `envFile: false` to `createServer`, which Vite 8 deprecated in favour of `envDir: false`. Pick the key from the installed Vite major so Vite 8 stops warning while the `>=5` peers keep the old key. Also reformats `packages/react-router-devtools/package.json`, which the release bot rewrote in becd7c9 without the Validation Pipeline running. That left `biome ci` failing on main, so every PR since inherits a red check.
1 parent cee8b01 commit a816df1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"react-router-devtools": patch
3+
---
4+
5+
Stop emitting the `envFile` deprecation warning on Vite 8.
6+
7+
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`.

packages/react-router-devtools/src/vite/node-server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ViteNodeRunner } from "vite-node/client"
33
import { ViteNodeServer } from "vite-node/server"
44
import { installSourcemapsSupport } from "vite-node/source-map"
55

6+
const viteMajor = Number(viteVersion.split(".")[0])
7+
68
// create vite server
79
const server = await createServer({
810
mode: "development",
@@ -17,11 +19,14 @@ const server = await createServer({
1719
noDiscovery: true,
1820
},
1921
configFile: false,
20-
envFile: false,
22+
// Vite 8 deprecated `envFile` in favour of `envDir: false` and warns when
23+
// it is passed. Older peers (>=5) only understand `envFile`, so pick the
24+
// key the installed Vite expects.
25+
...(viteMajor >= 8 ? ({ envDir: false } as const) : ({ envFile: false } as const)),
2126
plugins: [],
2227
})
2328
// For old Vite, this is need to initialize the plugins.
24-
if (Number(viteVersion.split(".")[0]) < 6) {
29+
if (viteMajor < 6) {
2530
await server.pluginContainer.buildStart({})
2631
}
2732

0 commit comments

Comments
 (0)