feat(cloudflare): support Vite dev bindings#622
Draft
agcty wants to merge 5 commits into
Draft
Conversation
86d932a to
1ac0e63
Compare
Contributor
Author
|
Final review update after the extra lifecycle pass:
Validation rerun:
One separate stack note: the local Durable Object build-manifest test still depends on the lower Cloudflare Vite manifest work emitting |
d3d317b to
3b9fc2f
Compare
39e2be9 to
2a8a850
Compare
2a8a850 to
d1b431f
Compare
cddae18 to
2f2f6e2
Compare
2f2f6e2 to
b160bfc
Compare
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.
Status / stack
Draft follow-up to #615. This PR is intentionally stacked on top of the manifest-consumer work:
viteEnvironmentchild environments.alchemy devfor Vite Workers with Alchemy-managed bindings.Because the stack crosses forks, GitHub cannot cleanly target this PR at the fork branch from #615 while still opening it against
alchemy-run/alchemy-effect. Until #615 lands, this PR's diff will include that base commit. After #615 merges, the diff should collapse to this follow-up commit.Refs #621.
Summary
alchemy devrestarts/rebinds a Vite Worker when Alchemy-managed binding identity or env values change.envcontains a bindable resource.//URLs.Cloudflare.Vitedev semantics: Vite owns the dev server/HMR loop; Alchemy owns resources and binding configuration.Architecture
This keeps the same line as #615:
In dev mode that means:
envinto the runtime binding hooks consumed by the distilled Cloudflare Vite plugin.alchemy.run.tschanges the binding set, Alchemy re-applies the resource graph and restarts/rebinds the local Vite Worker behind the same local URL.Verification
bun install --frozen-lockfilebun tsgo -b packages/alchemy/tsconfig.test.jsonbunx oxfmt --check ...git diff --checkbun run --filter alchemy test -- test/Cloudflare/Website/Vite.test.ts -t "Vite: ignores manifest-like files copied into client assets"bun run --filter alchemy test -- test/Cloudflare/Website/Vite.test.ts -t "Vite dev: TanStack Start keeps Alchemy-managed R2 bindings"Vite.viteBuild(...), producing client assets and an SSR bundle.http://localhost:1337: verified route render, R2 route write/read, HMR route edit, then restored the file and destroyed the manual Cloudflare stage.bun generate:api-referenceNotes
This does not add full remote Worker execution with Vite HMR. It hardens the local Vite HMR path with Alchemy-managed bindings, which matches the current official Cloudflare Vite plugin development model more closely.
Reviewer-round follow-ups
alchemy devapplies restarting unchanged Workers while still detecting binding/env/Vite/crons changes.viteEnvironment.nameoptional so Alchemy does not narrow the distilled plugin passthrough shape.bun.lockdistilled workspace version normalization reflects the already-checked-outdistilled/packages/*versions (0.25.1), not a separate submodule pointer change in this PR.Final lifecycle review follow-ups
dev: falseand external-dev-string Workers now diff from persisted props/bindings, not an in-memory stub hash, so no-op applies remain stable across provider restarts.build.rolldownOptions.external = ["cloudflare:workers"]; that default belongs to the Cloudflare Vite integration path, not each app fixture. The fixture also does not advertise standalonevite build, because Alchemy-managed dev/build is the path that injects the integration.Separate stack note
The local Durable Object build-manifest test still depends on the lower Cloudflare Vite manifest work emitting
__distilled-build.jsonfor that fixture. That remains part of the #615 / cloudflare-tools #50 stack rather than this dev-bindings follow-up.