Skip to content

fix: warn on deprecated envFile#22555

Open
SSDWGG wants to merge 2 commits into
vitejs:mainfrom
SSDWGG:codex/envfile-deprecation-warning
Open

fix: warn on deprecated envFile#22555
SSDWGG wants to merge 2 commits into
vitejs:mainfrom
SSDWGG:codex/envfile-deprecation-warning

Conversation

@SSDWGG
Copy link
Copy Markdown

@SSDWGG SSDWGG commented May 30, 2026

What changed

Why

envFile is already marked deprecated in the type definition, but the runtime path stayed silent. This makes migration harder for programmatic API users and leaves behavior inconsistent with other deprecated Vite options that warn when used.

Impact

Users who still pass envFile: false now get a clear migration hint without changing behavior. Consumers already on envDir: false keep the same experience with no extra warning.

Validation

  • pnpm vitest run packages/vite/src/node/__tests__/config.spec.ts -t "envFile option|envDir to disable env files"
  • pnpm exec eslint packages/vite/src/node/config.ts packages/vite/src/node/__tests__/config.spec.ts
  • pnpm exec oxfmt --check packages/vite/src/node/config.ts packages/vite/src/node/__tests__/config.spec.ts docs/guide/migration.md

@SSDWGG SSDWGG marked this pull request as ready for review May 30, 2026 09:45
@SSDWGG
Copy link
Copy Markdown
Author

SSDWGG commented May 30, 2026

I checked the remaining red check. The Vite CI matrix is green; the failing Run zizmor job appears unrelated to this change and fails before auditing this PR because it cannot list tags for actions-cool/issues-helper in .github/workflows/issue-close-require.yml (403 Forbidden from GitHub/git-upload-pack).

@truffle-dev
Copy link
Copy Markdown

One follow-up from the empirical pass on the linked issue: at HEAD, @react-router/dev still passes envFile: false in two internal child-compiler invocations (plugin.ts:1552 and vite-node.ts:61), and both sites are intentional ("child compiler suppresses env loading because the parent already handled it"), not migration debt. So as-is this warning will fire on every React Router dev/build against vite 8.x until they swap to envDir: false.

Existing precedent for that situation is at config.ts:1207-1213 — the optimizeDeps.esbuildOptions warning uses a "You or a plugin you are using have set ..." framing so end users know the warning is plugin-side and to ignore it until their plugin migrates. Same framing here would keep parity:

if (config.envFile === false) {
  logger.warn(
    colors.yellow(
      `You or a plugin you are using have set \`envFile: false\` ` +
        `but this option is now deprecated. ` +
        `Please use \`envDir: false\` instead.`,
    ),
  )
}

Conditional on the sequencing question on #22547 going this direction (rather than coordinating a React Router PR first). Either way the framing tweak is small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InlineConfig.envFile is deprecated but no runtime warning is emitted

2 participants