feat(cloudflare): consume distilled Vite manifests#615
Draft
agcty wants to merge 4 commits into
Draft
Conversation
7019e46 to
eb8fbd0
Compare
This was referenced Jun 16, 2026
630c06b to
205af29
Compare
Contributor
Author
|
Local verification / stack note, since this PR currently depends on the Cloudflare Tools side of the stack:
Example local linking shape: cd cloudflare-tools
git checkout feat/rsc-build
bun install
bun run build --filter='@distilled.cloud/cloudflare-vite-plugin' --filter='@distilled.cloud/cloudflare-rolldown-plugin'
cd ../alchemy-effect
bun install
rm packages/alchemy/node_modules/@distilled.cloud/cloudflare-vite-plugin
rm packages/alchemy/node_modules/@distilled.cloud/cloudflare-rolldown-plugin
ln -s /absolute/path/to/cloudflare-tools/packages/cloudflare-vite-plugin packages/alchemy/node_modules/@distilled.cloud/cloudflare-vite-plugin
ln -s /absolute/path/to/cloudflare-tools/packages/cloudflare-rolldown-plugin packages/alchemy/node_modules/@distilled.cloud/cloudflare-rolldown-plugin |
205af29 to
79fea45
Compare
ffcf665 to
98b9f7c
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 until the distilled Cloudflare Vite plugin side lands or publishes an equivalent manifest contract.
Dependency chain:
viteEnvironmentchild environments.__distilled-build.json, v2 shape).Cloudflare.Vite.This PR is intentionally scoped to consuming the distilled manifest and preserving Alchemy's existing resource/binding ownership model. It does not add remote Worker HMR;
alchemy devremains local Vite + local Cloudflare runtime, with supported bindings local or remote-backed depending on the binding type.Broader roadmap context is tracked in #621: Vite/framework owns the app entrypoint and Worker module graph, while Alchemy owns resources, bindings, deploy diffs, and uploads. That follow-up roadmap covers the polished
alchemy devbinding loop; this PR stays on the deploy-side manifest consumer.Summary
__distilled-build.jsonafter Vite builds and upload the manifest-selected Worker module set with explicit module content types.viteEnvironmenttopology into the distilled Vite build/dev plugin so RSC/custom Vite environment graphs use Alchemy's injected plugin consistently.hash.inputso VITE env, asset routing, compatibility, and topology-only changes do not get skipped.@vitejs/plugin-rsc;Cloudflare.Viteinjects the distilled Cloudflare Vite plugin and deploys the resulting manifest module set.Reviewer-round fixes
requireBuildManifestflag; any Vite server/Worker output now requires the distilled manifest.viteEnvironmentthroughalchemy dev, not just deploy.public/__distilled-build.jsoncopied into client assets cannot poison SPA/static builds.Redacted, while still only exposingVITE_primitives to the Vite build.Architecture
The supported path is one Vite-owned Worker with Alchemy-owned bindings:
This directly supports the common “one Vite Worker with bindings, including local Durable Object bindings” case without asking users to create a separate backend Worker. It avoids merging two fetch handlers; the Vite Worker exports the handler and DO classes, and Alchemy attaches the resources to that same Worker.
Verification
bun x oxfmt package.json packages/alchemy/package.json packages/alchemy/test/Cloudflare/Website/react-router-rsc-fixture/package.json packages/alchemy/test/Cloudflare/Website/Vite.test.ts packages/alchemy/test/Cloudflare/Website/react-router-rsc-fixturecd packages/alchemy && bun run buildpassed. The build still prints the existingcloudflare:workersexternal warning from the Workers runtime shim.bun run --filter alchemy test test/Cloudflare/Website/Vite.test.ts -t "Vite: React Router RSC deploys from a distilled manifest"passed against Cloudflare with a temporary scoped token. This direct-builds the RSC fixture, asserts the manifest main/module set/assets/compatibility shape, deploys throughCloudflare.Vite, verifies the deployed bundle hash matches the direct manifest bundle, hits/,/about, and/worker-render, then destroys the Worker.packages/alchemy/test/Cloudflare/Website/vite-do-fixture:alchemy devserved the app athttp://127.0.0.1:1337/; the browser showedVite DO fixture hydrated;/api/reset,/api/count, and/api/currentexercised the local DO binding.Notes / follow-ups
alchemy devcurrently gives local Vite HMR plus local distilled runtime, not remote Worker HMR. Some bindings are local-backed (for example local DOs/queues/services), while others use remote Cloudflare services (for example R2/KV/D1/Vectorize). Remote Worker HMR plus automatic infra reconciliation is a separate follow-up design.