fix: Formalize Vite startup validation guarantee and document the plugin contract - #1840
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Run failed. View the logs →
|
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@arkenv/agent-plugin
arkenv
@arkenv/build
@arkenv/bun-plugin
@arkenv/core
@arkenv/fumadocs-ui
@arkenv/nextjs
@arkenv/nuxt
@arkenv/rsbuild-plugin
@arkenv/standard
@arkenv/tanstack-addon
@arkenv/vite-plugin
commit: |
|
@pullfrog review |
There was a problem hiding this comment.
ℹ️ Minor suggestion only — the startup fail-fast and HMR revalidation contracts are accurately pinned by tests that pass.
Reviewed changes
- Vite / TanStack Start framework guides — added "When does validation run?" sections documenting plugin-registered startup validation during Vite config resolution, HMR revalidation of
.env/schema changes, and import-driven validation without the plugin; explicitly state that no default-off lazy-validation flag is added. @arkenv/vite-pluginreference — new "Startup validation" section recording the plugin contract, including the same HMR/import-driven distinction.- env-module.test.ts — three regression tests: fail-fast rejection with an
ArkEnvErrorfromconfigResolvedfor a missing value (plus a zero-pollutionprocess.envassertion), valid schema/dotenv HMR invalidation, and invalid dotenv values propagating throughhandleHotUpdate.
I built the workspace and ran the full @arkenv/vite-plugin suite — all 17 tests pass, and the new tests individually exercise configResolved/handleHotUpdate against the real transform-plugin.ts implementation. The documented behavior matches the code path (configResolved → resolveEnvModulePath + loadValidatedEnv rethrow; handleHotUpdate → refreshTransformState rethrow under "Environment validation failed during HMR"). Biome and mdxlint are clean on all changed files. No changeset is needed (tests + docs only, and it was correctly removed).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- HMR happy-path revalidation now asserts substance — after the dotenv
handleHotUpdate, the test rewrites.env.test, keeps the module-invalidation length check, then transforms the schema in a client-graph context and asserts the regenerated module inlines the updatedVITE_API_URL. A regression whererefreshTransformStatestops re-reading values now goes red instead of passing on a baretoHaveLength(1).
This delta is the direct fix for the prior review's suggestion, and the rest of the PR (docs + the two other regression tests) was already reviewed at e2b102c1. I rebuilt the workspace and ran packages/vite-plugin/src/env-module.test.ts — all 17 tests pass, including revalidates valid schema and dotenv changes during HMR. The new assertion is falsifiable: with refresh dropped, state.clientValues would still hold https://example.com from configResolved, so the https://updated.example.com containment check would fail.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Fixes #1837
Added regression coverage for config-resolution validation and successful/failed HMR revalidation. Documented plugin-present startup validation versus plugin-absent import-driven validation across the Vite and TanStack Start guides and the plugin reference. No lazy-validation flag was introduced.