Skip to content

fix: keep runnerImport from setting NODE_ENV (fix #20299) - #24202

Closed
Israel-Kli wants to merge 1 commit into
vitejs:mainfrom
Israel-Kli:fix/20299-runner-import-node-env
Closed

Israel-Kli wants to merge 1 commit into
vitejs:mainfrom
Israel-Kli:fix/20299-runner-import-node-env

Conversation

@Israel-Kli

Copy link
Copy Markdown

runnerImport calls resolveConfig with the serve command, which defaults an unset process.env.NODE_ENV to development. That default stays on the process after the import, so a later build() can run as development. This fixes #20299 by saving NODE_ENV before resolveConfig and restoring it afterwards when it was unset or empty and is still the default. A value set by a config hook is left alone.

Alternative considered: changing resolveConfig itself. That would also change createServer and build, where the default is intended (#18712), so the fix stays in runnerImport.

For reviewers: with NODE_ENV unset, the imported module now evaluates without it instead of with development; the CLI path is unaffected because its outer config resolution sets the value first. A concurrent build() during runnerImport can still see the default.

AI disclosure: I used Claude Code to write the change and the tests. I reviewed the diff, ran the unit tests (8 passed), lint and format locally, and confirmed the new tests fail without the source change and when an assertion is altered. Full suites and typecheck are left to CI.

@github-actions github-actions Bot added the bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically flagged as likely to be created by a bot, LLM, or agent, and will be automatically closed. These contributions harm the maintenance of the project. Please read our AI policy for more information.

If you believe this is a mistake, please reply to this comment and we will review it.

@github-actions github-actions Bot closed this Nov 24, 2026
@Israel-Kli

Copy link
Copy Markdown
Author

There's a person behind this PR, and I'm responsible for it. I used Claude Code to write the change and its tests, as the description says, and I'll follow up on review comments.

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

Labels

bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runnerImport sets process.env.NODE_ENV to development

1 participant