workers-sdk / vite-plugin-cloudflare
AGENTS.md4.6k starsChanged 6 months agoApache-2.0View on GitHub
Vite plugin for Cloudflare Workers development. Exports cloudflare() plugin factory from src/index.ts. ESM-only output. bin/cf-vite is an experimental, internal delegate binary spawned by Cloudflare's "cf-dev" parent process — NOT part of the plugin's public API and not meant for direct end-user invocation. It is the sibling of wrangler's cf-wrangler binary, and the two MUST keep a shared spawn contract so the parent can drive either impl interchangeably. - Verb dispatch. cf-vite <verb> [flags]. dev and build are the verbs today;…
- Reads credentials
Trending
Quiet since August.about the whole repository
Who's talking about cloudflare/workers-sdk
- cloudflare/workerd“🐛 BUG: The cache field on RequestInitializerDict is not implemented in fetch”GitHub · Apr 7, 2023 · 85 reactions
- sveltejs/kit“feat: Vite environment API”GitHub · Jul 17, 2025 · 31 reactions
- remix-run/remix“Cloudflare support for Vite”GitHub · Jan 16, 2024 · 25 reactions
- cloudflare/workerd“🐛 BUG: Workers TTFB slows down based on unused dynamic imports (additional modules)”GitHub · Mar 27, 2024 · 22 reactions
- withastro/astro“Cloudflare adapter returning [object Object]”GitHub · Oct 10, 2025 · 18 reactions
The biggest 5 of 17 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 17
Talked about on GitHub, Bluesky and Hacker News (17 times).
On GitHub · 14
- Apr 7, 2023🐛 BUG: The cache field on RequestInitializerDict is not implemented in fetch — cloudflare/workerd85 reactions · 61 comments
- Jul 17, 2025feat: Vite environment API — sveltejs/kit31 reactions · 16 comments
- Jan 16, 2024Cloudflare support for Vite — remix-run/remix25 reactions · 21 comments
- Mar 27, 2024🐛 BUG: Workers TTFB slows down based on unused dynamic imports (additional modules) — cloudflare/workerd22 reactions · 6 comments
- Oct 10, 2025Cloudflare adapter returning [object Object] — withastro/astro18 reactions · 15 comments
9 more on GitHub
- May 24, 2023Support Node Compat in Cloudflare Adaptor — sveltejs/kit17 reactions · 2 comments
- Oct 17, 2024Support Wrangler, the CLI for Cloudflare Workers — denoland/deno15 reactions · 8 comments
- Aug 10, 2026feat: `@cloudflare/vite-plugin` integration, take 2 — sveltejs/kit11 reactions · 5 comments
- Jul 22, 2023Feature Request — Runtime APIs: Superfluous throws — cloudflare/workerd11 reactions
- Oct 29, 2025Add --target=cloudflare support to bundler — oven-sh/bun8 reactions · 10 comments
- Nov 6, 2025placement just got better (finally) — cloudflare/cloudflare-docs7 reactions · 6 comments
- Oct 28, 2025vitest 4.0 fails with "TypeError: filename.replace is not a function" — withastro/astro7 reactions · 3 comments
- May 23, 2025'scopes' for Secret Store's secrets not retained in local development — cloudflare/developer-platform7 reactions · 7 comments
- Jul 23, 2024bun fetch to wrangler dev server crashes server and fails with "socket connection was closed unexpectedly" — oven-sh/bun7 reactions · 20 comments
On Bluesky · 2
- Oct 20, 2023📦 cloudflare / workers-sdk ⭐ 1,781 (+48) 🗒 TypeScript ⛅️ Home to Wrangler, the CLI for Cloudflare Workers® — @github-trending-js.bsky.social1 likes and repost
- Oct 20, 2023📦 cloudflare / workers-sdk ⭐ 1,734 (+4) 🗒 TypeScript ⛅️ Home to Wrangler, the CLI for Cloudflare Workers® — @github-trending.bsky.social1 likes and repost
On Hacker News · 1
- May 2, 2026Cloudflare Workers let you deploy serverless code instantly across the globe3 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- packages/auto-triage-bot/AGENTS.mdAGENTS.md
- packages/create-cloudflare/AGENTS.mdAGENTS.md
- packages/miniflare/AGENTS.mdAGENTS.md
- packages/vitest-plugin/AGENTS.mdAGENTS.md
- packages/workers-auth/AGENTS.mdAGENTS.md
- packages/workers-utils/AGENTS.mdAGENTS.md
- packages/wrangler/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- local-explorerSkill
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Only package using tsdown as build tool
- Very specific: line 39
Do NOT add flags here unless cf-wrangler grows them too.
- Very specific: line 81
No named imports from "wrangler" — must use import * as wrangler from "wrangler" (namespace import only, enforced by eslint)
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — vite-plugin-cloudflare
OVERVIEW
Vite plugin for Cloudflare Workers development. Exports cloudflare() plugin factory from src/index.ts. ESM-only output.
STRUCTURE
src/index.ts— Plugin factory (uses top-levelawaitforassertWranglerVersion())src/cf-vite.ts—cf-vitedelegate binary entry (see below)bin/cf-vite— shebang shim that dynamic-importsdist/cf-vite.mjssrc/workers/— 4 internal worker entries:asset-worker,router-worker,runner-worker,vite-proxy-workerplayground/— ~47 playground apps, each a workspace member (nested workspace under this package)e2e/— E2E tests with Playwright__tests__/— Unit tests use.spec.tsnaming
BUILD
- Only package using
tsdownas build tool - Outputs ESM (
.mjs) todist/index.mjs src/cf-vite.tsis a second top-level tsdown entry, bundled todist/cf-vite.mjs(no dts)- Also bundles 4 internal worker scripts from
src/workers/*/index.tsas separate neutral-platform outputs todist/workers/
cf-vite DELEGATE BINARY (experimental / internal)
bin/cf-vite is an experimental, internal delegate binary spawned by
Cloudflare's "cf-dev" parent process — NOT part of the plugin's public
API and not meant for direct end-user invocation. It is the sibling of
wrangler's cf-wrangler binary, and the two MUST keep a shared spawn
contract so the parent can drive either impl interchangeably.
- Verb dispatch.
cf-vite <verb> [flags].devandbuildare the verbs today; future verbs (deploy) follow the same shape. Unknown/missing verbs exit2(this doubles as the parent's version-detection signal — no JSON handshake). - Shared flag vocabulary (
dev). Fordev, only--mode,--port,--host,--localare accepted, mirroringcf-wranglerexactly. Parsed withnode:util.parseArgsstrict mode → unknown flags exit2. Do NOT add flags here unlesscf-wranglergrows them too. (There is no--configflag: the wrangler config is discovered bycloudflare()itself.) buildcf-vite buildruns Vite's full multi-environment app build viacreateBuilder().buildApp()(NOT the legacy single-environmentbuild()helper, which would skip the plugin's worker/build-output orchestration — mirrors Vite's ownvite buildCLI). It accepts only--mode(--port/--host/--localdon't apply to a build and exit2). Preview build context is supplied throughCLOUDFLARE_PREVIEW_BUILD, which also works when a framework runs Vite as part of its own build command.- Build Output Specification forced for every verb.
main()setsCLOUDFLARE_VITE_FORCE_BUILD_OUTPUTunconditionally (before Vite loads the user's config), enablingexperimental.newConfig+experimental.newConfig.cfBuildOutput(overriding plugin config), which requires acloudflare.config.tsat the project root. The env var name and read logic live inbuild-output-env.ts(FORCE_BUILD_OUTPUT_ENV_VAR/isForcedBuildOutput()), shared by the two read sites that MUST agree:index.ts(selects the build-output plugin at construction) andresolvePluginConfig. Both read directly fromprocess.env(NOT Vite'sloadEnv), sinceindex.tsruns before Vite resolves a root/mode and this is an internal bridge, not a.env-file knob. devcf-vite devboots Vite viacreateServer()against the user's ownvite.config.ts(which must includecloudflare()). Plugin-owned flags are bridged via env vars the plugin already reads (--local→CLOUDFLARE_VITE_FORCE_LOCAL); Vite-owned flags go through inline config (--port/--host→server.*,--mode→mode).--localforces remote bindings off. There is no plugin env knob forremoteBindingsother thanCLOUDFLARE_VITE_FORCE_LOCAL, whichresolvePluginConfiginplugin-config.tshonours by overriding theremoteBindingsconfig option. Keep that override in sync if the flag semantics change.- Hotkeys differ by design.
cf-viteuses Vite's ownbindCLIShortcuts(h/r/q/…), not wrangler's hotkey set. The parent process should not assume identical hotkey UX across delegates. - Exit codes.
0graceful,2unknown verb / argv parse error,130SIGINT,143SIGTERM.
CONVENTIONS
- No named imports from
"wrangler"— must useimport * as wrangler from "wrangler"(namespace import only, enforced by eslint) - Top-level
awaitin entry — only possible because ESM-only - Playground directory
worker-♫/has unicode in name (intentional)
TESTING
- Unit tests:
.spec.tsin__tests__/ - E2E tests:
.test.tsine2e/, own vitest config - Playground tests: Playwright-based, tested across Vite 6/7/8 in CI
- Playground request helpers (
playground/__test-utils__/responses.ts):getTextResponse()/getJsonResponse()issue a request with browser navigation headers (Sec-Fetch-Mode: navigateet al), which the asset and router workers branch on. Default to these.- They use undici's low-level
request()rather thanfetch()deliberately. The Fetch spec requires implementations to setSec-Fetch-Modefrom the request'smode("append the Fetch metadata headers"), sofetch()overwrites whatever the caller passed withcorsbefore the request leaves the process (appendFetchMetadatain undici).Sec-Fetch-Dest/-Site/-Userare unimplemented there, so they survive — which is why onlySec-Fetch-Modebreaks and it is easy to miss. That one decides whether the asset worker appliesnot_found_handling. - This is permanent, not a bug to wait out: no Fetch-based API can send
Sec-Fetch-Mode: navigate, andfetch(url, { mode: "navigate" })is rejected by theRequestconstructor. Do not "simplify" these back tofetch();spa-with-api's "viagetTextResponse()" test exists to catch exactly that regression (it is the only playground whose compat date enablesSEC_FETCH_MODE_NAVIGATE_HEADER_PREFERS_ASSET_SERVING). getResponse()drives a realpage.goto()and returns a PlaywrightResponse. Only use it when the assertion needs the browser. Anything routed through Playwright can outlive a timed-out test and surface as an unhandled rejection, which fails the whole run rather than one test.WAIT_FOR_OPTIONS(playground/__test-utils__/index.ts) must stay comfortably below the test timeout, otherwisevi.waitFor()never gets to report the assertion that was actually failing.
playground/vitest.config.e2e.tsinherits the repo-wide timeouts andretry: 1from the rootvitest.shared.ts. It spreadsconfigShared.testrather than usingmergeConfig(), which concatenates arrays and would silently enable the shareddefaultreporter alongsidedot.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

