fix: cloudflare + tanstack start + vite 6/7/8 compatibility#690
Merged
Conversation
- Fix duplicate SSR init injection when TanStack Start + Cloudflare detect multiple entry modules in the same environment (dedup via Set keyed by environment name, build-mode only) - Fix Vite 6 dev mode crash: `isEntry` property throws in dev, wrapped in try/catch with fallback to moduleIds[0] - Fix Vite dep optimizer breaking varlock/env in CF worker environments: exclude varlock packages from optimizeDeps via configEnvironment (Vite 7+) and configResolved (Vite 6 fallback) - Add preview env injection for CF builds via FIFO named pipe so secrets never touch disk (Windows falls back to temp file) - Split vite and cloudflare framework tests by version (v5-v8) - Add TanStack Start framework tests (node + cloudflare, vite 6/7/8) - Register tanstack-start in CI integration detection
Contributor
|
The changes in this PR will be included in the next version bump.
|
commit: |
Verifies ENV.x works at module top-level (not just inside handlers) for both node and cloudflare targets across vite 6/7/8.
Adds ENV.x access at module evaluation time (outside fetch handler) to the basic worker. This currently fails because initVarlockEnv() runs after the worker module body in the bundled output.
Replaces inline init code injection with a virtual module import (`\0varlock-ssr-init`). The virtual module has no transitive dependencies on user code, so the bundler evaluates it first in the concatenated output — ensuring initVarlockEnv() runs before any user modules that access ENV at the top level. Previously, init code was appended to the entry module's body, which ran last in the bundle after all statically-imported user modules had already been evaluated.
The virtual module approach makes dedup unnecessary — ES modules evaluate only once regardless of how many entries import them.
Throw a clear error if a .dev.vars file exists at the project root (during dev/build) or in the build output (during preview), since it conflicts with varlock's automatic env injection.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
varlock-website | e5f658c | Commit Preview URL Branch Preview URL |
May 05 2026, 05:30 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fixes compatibility issues with the varlock vite and cloudflare integrations across Vite 6, 7, and 8, particularly when used with TanStack Start.
Vite integration fixes
isEntrycrash: AccessinggetModuleInfo(id).isEntryin Vite 6 dev mode throws instead of returning false. Wrapped in try/catch with fallback tomoduleIds[0].varlock/env: In Cloudflare worker environments, the dep optimizer would pre-bundlevarlock/envand then lose the file after re-optimization. Fixed by excluding varlock packages fromoptimizeDepsviaconfigEnvironment(Vite 7+) andconfigResolved(Vite 6 fallback).Cloudflare integration fixes
vite previewsoinitVarlockEnvcan find env vars in miniflare. Secrets never touch disk on Unix (FIFO named pipe); Windows falls back to a temp file.Test coverage
tanstack-startin CI integration detectionTest plan