Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/lemon-colts-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/vite-plugin": minor
"@cloudflare/vitest-pool-workers": minor
"wrangler": minor
---

Enable Remote Bindings without the need for the `--x-remote-bindings` flag
1 change: 0 additions & 1 deletion fixtures/ai-app/.gitignore

This file was deleted.

24 changes: 0 additions & 24 deletions fixtures/ai-app/package.json

This file was deleted.

13 changes: 0 additions & 13 deletions fixtures/ai-app/src/index.js

This file was deleted.

40 changes: 0 additions & 40 deletions fixtures/ai-app/tests/index.test.ts

This file was deleted.

7 changes: 0 additions & 7 deletions fixtures/ai-app/tests/tsconfig.json

This file was deleted.

13 changes: 0 additions & 13 deletions fixtures/ai-app/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions fixtures/ai-app/vitest.config.mts

This file was deleted.

8 changes: 0 additions & 8 deletions fixtures/ai-app/wrangler.jsonc

This file was deleted.

16 changes: 6 additions & 10 deletions fixtures/get-platform-proxy-remote-bindings/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteWorkerName,
experimental_remote: true,
remote: true,
},
],
kv_namespaces: [
{
binding: "MY_KV",
id: remoteKvId,
experimental_remote: true,
remote: true,
},
],
env: {
Expand All @@ -108,14 +108,14 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteStagingWorkerName,
experimental_remote: true,
remote: true,
},
],
kv_namespaces: [
{
binding: "MY_KV",
id: remoteKvId,
experimental_remote: true,
remote: true,
},
],
},
Expand All @@ -137,7 +137,6 @@ if (auth) {
MY_KV: KVNamespace;
}>({
configPath: "./.tmp/normal-usage/wrangler.json",
experimental: { remoteBindings: true },
});

const response = await fetchFromWorker(env.MY_WORKER, "OK");
Expand All @@ -160,7 +159,6 @@ if (auth) {
MY_KV: KVNamespace;
}>({
configPath: "./.tmp/normal-usage/wrangler.json",
experimental: { remoteBindings: true },
environment: "staging",
});

Expand Down Expand Up @@ -219,7 +217,7 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteWorkerName,
experimental_remote: true,
remote: true,
},
],
},
Expand All @@ -233,7 +231,6 @@ if (auth) {
MY_WORKER: Fetcher;
}>({
configPath: "./.tmp/config-with-invalid-account-id/wrangler.json",
experimental: { remoteBindings: true },
});

const response = await fetchFromWorker(env.MY_WORKER, "OK", 10_000);
Expand All @@ -257,7 +254,7 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteWorkerName,
experimental_remote: true,
remote: true,
},
],
},
Expand All @@ -271,7 +268,6 @@ if (auth) {
MY_WORKER: Fetcher;
}>({
configPath: "./.tmp/config-with-no-account-id/wrangler.json",
experimental: { remoteBindings: true },
});

const response = await fetchFromWorker(env.MY_WORKER, "OK");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default defineWorkersConfig({
include: ["test-staging/**/*.spec.ts"],
poolOptions: {
workers: {
experimental_remoteBindings: true,
wrangler: { configPath: "./wrangler.json", environment: "staging" },
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default defineWorkersConfig({
include: ["test/**/*.spec.ts"],
poolOptions: {
workers: {
experimental_remoteBindings: true,
wrangler: { configPath: "./wrangler.json" },
},
},
Expand Down
4 changes: 2 additions & 2 deletions fixtures/vitest-pool-workers-remote-bindings/wrangler.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"binding": "MY_WORKER",
"service": "my-worker-test",
"experimental_remote": true
"remote": true
}
],
"env": {
Expand All @@ -15,7 +15,7 @@
{
"binding": "MY_WORKER",
"service": "my-staging-worker-test",
"experimental_remote": true
"remote": true
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"binding": "REMOTE_WORKER",
"service": "<<REMOTE_WORKER_PLACEHOLDER_ALT>>",
"experimental_remote": true,
"remote": true,
},
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
{
"binding": "LOCAL_WORKER",
"service": "cloudflare-vite-e2e-remote-bindings-auxiliary-worker",
"experimental_remote": false,
"remote": false,
},
{
"binding": "REMOTE_WORKER",
"service": "<<REMOTE_WORKER_PLACEHOLDER>>",
"experimental_remote": true,
"remote": true,
},
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default defineConfig({
],
inspectorPort: false,
persistState: false,
experimental: { remoteBindings: true },
}),
],
});
48 changes: 24 additions & 24 deletions packages/vite-plugin-cloudflare/src/miniflare-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import type {
import type { MiniflareOptions, WorkerOptions } from "miniflare";
import type { FetchFunctionOptions } from "vite/module-runner";
import type {
Experimental_RemoteProxySession,
remoteProxySession,
SourcelessWorkerOptions,
Unstable_Binding,
} from "wrangler";
Expand Down Expand Up @@ -230,7 +230,7 @@ function logUnknownTails(
const remoteProxySessionsDataMap = new Map<
string,
{
session: Experimental_RemoteProxySession;
session: remoteProxySession;
remoteBindings: Record<string, Unstable_Binding>;
} | null
>();
Expand Down Expand Up @@ -396,16 +396,16 @@ export async function getDevMiniflareOptions(config: {
? remoteProxySessionsDataMap.get(workerConfig.configPath)
: undefined;

const remoteProxySessionData = resolvedPluginConfig.experimental
.remoteBindings
? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySession ?? null
)
: undefined;
const remoteProxySessionData =
resolvedPluginConfig.experimental.remoteBindings ?? true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this experimental property still valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see #10604 (comment)

? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySession ?? null
)
: undefined;

if (workerConfig.configPath && remoteProxySessionData) {
remoteProxySessionsDataMap.set(
Expand All @@ -425,7 +425,7 @@ export async function getDevMiniflareOptions(config: {
remoteProxySessionData?.session
?.remoteProxyConnectionString,
remoteBindingsEnabled:
resolvedPluginConfig.experimental.remoteBindings,
resolvedPluginConfig.experimental.remoteBindings ?? true,
containerBuildId,
}
);
Expand Down Expand Up @@ -726,16 +726,16 @@ export async function getPreviewMiniflareOptions(config: {
? remoteProxySessionsDataMap.get(workerConfig.configPath)
: undefined;

const remoteProxySessionData = resolvedPluginConfig.experimental
.remoteBindings
? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySessionData ?? null
)
: undefined;
const remoteProxySessionData =
resolvedPluginConfig.experimental.remoteBindings ?? true
? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySessionData ?? null
)
: undefined;

if (workerConfig.configPath && remoteProxySessionData) {
remoteProxySessionsDataMap.set(
Expand All @@ -751,7 +751,7 @@ export async function getPreviewMiniflareOptions(config: {
remoteProxyConnectionString:
remoteProxySessionData?.session?.remoteProxyConnectionString,
remoteBindingsEnabled:
resolvedPluginConfig.experimental.remoteBindings,
resolvedPluginConfig.experimental.remoteBindings ?? true,
containerBuildId,
}
);
Expand Down
Loading
Loading