Skip to content

Commit fac2f9d

Browse files
feat(vite-plugin-cloudflare): enable cross-process service bindings with dev registry (#9173)
* feat(miniflare): introduce getDefaultDevRegistryPath API * feat(vite-plugin-cloudflare): enable dev registry * fix(miniflare): adjust proxy style for better compatibility with wrangler * chore(@fixture/dev-registry): add test fixture * add changeset * align fixture vitest config * Update packages/vite-plugin-cloudflare/playground/multi-worker/__tests__/multi-worker.spec.ts * Update packages/vite-plugin-cloudflare/src/miniflare-options.ts --------- Co-authored-by: James Opstad <[email protected]>
1 parent ac0f1ad commit fac2f9d

31 files changed

+1011
-32
lines changed

.changeset/bright-cloths-turn.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
"@cloudflare/vite-plugin": minor
3+
---
4+
5+
Enable cross-process Service bindings and Tail workers with the Dev Registry
6+
7+
You can now run workers in separate dev sessions—whether `vite dev` or `wrangler dev`—and they’ll automatically discover and connect to each other:
8+
9+
**Worker A**
10+
11+
```jsonc
12+
// ./worker-a/wrangler.jsonc
13+
{
14+
"name": "worker-a",
15+
"main": "./src/index.ts",
16+
"services": [
17+
{
18+
"binding": "SERVICE",
19+
"service": "worker-b",
20+
},
21+
],
22+
}
23+
```
24+
25+
**Worker B**
26+
27+
```jsonc
28+
// ./worker-b/wrangler.jsonc
29+
{
30+
"name": "worker-b",
31+
"main": "./src/index.ts",
32+
"tail_consumers": [
33+
{
34+
"service": "worker-a",
35+
},
36+
],
37+
}
38+
```
39+
40+
Then run both workers in separate terminals:
41+
42+
```sh
43+
# Terminal 1
44+
cd worker-a
45+
vite dev
46+
47+
# Terminal 2
48+
cd worker-b
49+
vite dev
50+
# or `wrangler dev` if you prefer
51+
```
52+
53+
That's it!

.changeset/rich-nails-taste.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"miniflare": minor
3+
---
4+
5+
feat: export `getDefaultDevRegistryPath()` utility
6+
7+
This provides a default XDG app-path for the Dev Registry, which can be used to set the `unsafeDevRegistryPath` option in Miniflare and will be used by both Wrangler and @cloudflare/vite-plugin.

fixtures/dev-registry/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@fixture/dev-registry",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"check:types": "tsc --build",
7+
"test": "vitest",
8+
"test:ci": "vitest run",
9+
"vite": "vite dev",
10+
"wrangler": "wrangler dev"
11+
},
12+
"devDependencies": {
13+
"@cloudflare/vite-plugin": "workspace:*",
14+
"@cloudflare/workers-tsconfig": "workspace:*",
15+
"@cloudflare/workers-types": "^4.20250508.0",
16+
"typescript": "catalog:default",
17+
"vite": "catalog:vite-plugin",
18+
"vitest": "catalog:default",
19+
"wrangler": "workspace:*"
20+
}
21+
}

0 commit comments

Comments
 (0)