Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/v1-lazy-wrangler-log-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/vite-plugin": patch
---

Respect `WRANGLER_LOG_PATH` set after importing the plugin in `vite.config.ts`

Require Wrangler 4.168.0 or newer, which resolves the debug log path on first use. A path set in the Vite configuration body now selects the configured log file.
7 changes: 7 additions & 0 deletions .changeset/v1-runtime-20261123.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/vite-plugin": patch
Comment thread
petebacondarwin marked this conversation as resolved.
Resolved
---

Update the local runtime and default compatibility date to November 23

Use Miniflare 5.20261123.1-beta, workerd 1.20261123.1 and the matching Workers types. The default compatibility date advances to November 23. Local Stream bindings support caption retrieval and video customer codes; R2 pagination uses UTF-8 key order, and KV bulk reads preserve metadata for stored JSON nulls.
2 changes: 1 addition & 1 deletion fixtures/dev-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"typescript": "catalog:default",
"vite": "catalog:default",
"vitest": "catalog:default",
"wrangler": "4.166.0"
"wrangler": "4.168.0"
}
}
4 changes: 2 additions & 2 deletions fixtures/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"description": "Shared fixtures for testing",
"devDependencies": {
"@cloudflare/workers-utils": "0.56.0",
"wrangler": "4.166.0"
"@cloudflare/workers-utils": "0.57.0",
"wrangler": "4.168.0"
}
}
2 changes: 1 addition & 1 deletion packages/mock-npm-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:ci": "vitest run"
},
"devDependencies": {
"@cloudflare/workers-utils": "0.56.0",
"@cloudflare/workers-utils": "0.57.0",
"@types/node": "catalog:default",
"@verdaccio/types": "^10.8.0",
"get-port": "^7.0.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/remote-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"test:watch": "vitest"
},
"dependencies": {
"@cloudflare/cli-shared-helpers": "0.3.12",
"@cloudflare/deploy-helpers": "0.29.0",
"@cloudflare/workers-auth": "0.18.6",
"@cloudflare/workers-utils": "0.56.0",
"@cloudflare/cli-shared-helpers": "0.3.13",
"@cloudflare/deploy-helpers": "0.29.1",
"@cloudflare/workers-auth": "0.18.8",
"@cloudflare/workers-utils": "0.57.0",
"chalk": "catalog:default",
"miniflare": "5.20261119.0-beta",
"miniflare": "5.20261123.1-beta",
"undici": "catalog:default",
"ws": "catalog:default"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@cloudflare/vite-plugin": "*",
"@cloudflare/workers-types": "^5.20260706.1",
"globals": "^15.14.0",
"miniflare": "5.20261119.0-beta",
"miniflare": "5.20261123.1-beta",
"typescript": "~5.7.2",
"vite": "^8.0.0",
"wrangler": "*"
Expand Down
10 changes: 5 additions & 5 deletions packages/vite-plugin-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
},
"dependencies": {
"@cloudflare/unenv-preset": "2.16.2",
"miniflare": "5.20261119.0-beta",
"miniflare": "5.20261123.1-beta",
"unenv": "2.0.0-rc.24",
"wrangler": "4.166.0",
"wrangler": "4.168.0",
"ws": "8.22.0"
},
"devDependencies": {
Expand All @@ -57,8 +57,8 @@
"@cloudflare/remote-bindings": "workspace:*",
"@cloudflare/workers-shared": "workspace:*",
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "5.20261119.1",
"@cloudflare/workers-utils": "0.56.0",
"@cloudflare/workers-types": "5.20261123.1",
"@cloudflare/workers-utils": "0.57.0",
"@remix-run/node-fetch-server": "1.0.0",
"@types/node": "22.15.17",
"@types/semver": "7.8.0",
Expand All @@ -82,7 +82,7 @@
},
"peerDependencies": {
"vite": "^6.1.0 || ^7.0.0 || ^8.0.0",
"wrangler": "^4.166.0"
"wrangler": "^4.168.0"
},
"workers-sdk": {
"prerelease": true
Expand Down
71 changes: 71 additions & 0 deletions packages/vite-plugin-cloudflare/src/__tests__/log-path.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { execFile } from "node:child_process";
import * as fs from "node:fs/promises";
import { promisify } from "node:util";
import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers";
import { afterEach, test, vi } from "vitest";

const execFileAsync = promisify(execFile);
const pluginUrl = new URL("../../dist/index.mjs", import.meta.url).href;
const viteUrl = import.meta.resolve("vite");

runInTempDir();
afterEach(() => vi.unstubAllEnvs());

test("respects WRANGLER_LOG_PATH set in the Vite config after importing the plugin", async ({
expect,
}) => {
await seed({
"wrangler.json": JSON.stringify({
name: "log-path",
main: "./index.js",
compatibility_date: "2026-04-01",
}),
"index.js": 'export default { fetch: () => new Response("ok") };',
"vite.config.mjs": `
import { cloudflare } from ${JSON.stringify(pluginUrl)};
process.env.WRANGLER_LOG_PATH = "configured-logs/vite.log";
export default {
plugins: [cloudflare({ inspectorPort: false, persistState: false, remoteBindings: false })],
server: { watch: null }
};
`,
});
// A fresh process preserves the original import-before-configuration order,
// without a debug-log path cached by another plugin test.
// Expand Windows 8.3 directory names so Vite resolves the Worker entry.
const root = await fs.realpath(process.cwd());
await execFileAsync(
process.execPath,
[
"--input-type=module",
"--eval",
`
import assert from "node:assert";
import { createServer } from ${JSON.stringify(viteUrl)};
const server = await createServer();
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
try {
await server.listen(0);
const url = server.resolvedUrls?.local[0];
assert(url);
assert.equal(await (await fetch(url)).text(), "ok");
} finally {
await server.close();
}
`,
],
{
cwd: root,
env: {
...process.env,
PWD: root,
WRANGLER_LOG_PATH: "",
WRANGLER_WRITE_LOGS: "true",
WRANGLER_SEND_METRICS: "false",
},
timeout: 30_000,
}
);
expect(await fs.readFile("configured-logs/vite.log", "utf8")).toContain(
"---"
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,7 @@ describe("resolvePluginConfig - zero-config mode", () => {

expect(result.type).toBe("assets-only");
const assetsOnlyResult = result as AssetsOnlyResolvedConfig;
expect(assetsOnlyResult.config.compatibility_date).toBe(
DEFAULT_COMPAT_DATE
);
expect(assetsOnlyResult.config.compatibility_date).toBe("2026-11-23");
});

test("should allow config() to add main in zero-config mode", async ({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import assert from "node:assert";
import * as fs from "node:fs/promises";
import { cloudflare } from "@cloudflare/vite-plugin";
import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers";
import { createServer } from "vite";
import { afterEach, beforeEach, describe, test, vi } from "vitest";

describe("local runtime bindings through Vite", () => {
runInTempDir();
afterEach(() => vi.unstubAllEnvs());
beforeEach(async () => {
if (process.platform === "win32") {
const root = await fs.realpath(process.cwd());
process.chdir(root);
vi.stubEnv("PWD", root);
}
await seed({
"wrangler.json": JSON.stringify({
name: "runtime-bindings",
main: "./index.js",
compatibility_date: "2026-04-01",
stream: { binding: "STREAM" },
r2_buckets: [{ binding: "BUCKET", bucket_name: "runtime-bucket" }],
kv_namespaces: [{ binding: "KV", id: "runtime-kv" }],
}),
"index.js": `
export default {
async fetch(request, env) {
switch (new URL(request.url).pathname) {
case "/stream": {
const video = await env.STREAM.upload(new Response(new Uint8Array([0, 1, 2, 3])).body);
const captions = env.STREAM.video(video.id).captions;
await captions.upload("en", new Response("test").body);
await captions.generate("fr");
const uploaded = await new Response(await captions.get("en")).text();
const generated = await new Response(await captions.get("fr")).text();
let missing;
try { await captions.get("de"); } catch (error) { missing = error.message; }
return Response.json({ customerCode: video.customerCode, uploaded, generated, missing });
}
case "/r2": {
for (const key of ["A", "📷", "📸"]) await env.BUCKET.put(key, "value");
const first = await env.BUCKET.list({ startAfter: "A", limit: 1 });
const second = await env.BUCKET.list({ startAfter: "A", limit: 1, cursor: first.cursor });
return Response.json([first, second].map(page => page.objects.map(object => object.key)));
}
case "/kv": {
await env.KV.put("null", "null", { metadata: { testing: "null" } });
const values = await env.KV.getWithMetadata(["null", "missing"], "json");
return Response.json(Object.fromEntries(values));
}
}
return new Response("not found", { status: 404 });
}
};
`,
});
});

test.for([
{
path: "/stream",
result: {
customerCode: "placeholder",
uploaded: "test",
generated: "WEBVTT\n",
missing: "Caption not found",
},
},
{ path: "/r2", result: [["📷"], ["📸"]] },
{
path: "/kv",
result: {
null: { value: null, metadata: { testing: "null" } },
missing: null,
},
},
])(
"serves $path with the released runtime behavior",
async ({ path, result }, { expect, onTestFinished }) => {
const server = await createServer({
root: process.cwd(),
configFile: false,
logLevel: "silent",
server: { watch: null },
plugins: [
cloudflare({
inspectorPort: false,
persistState: false,
remoteBindings: false,
}),
],
});
onTestFinished(() => server.close());
await server.listen(0);
const url = server.resolvedUrls?.local[0];
assert(url);
const response = await fetch(new URL(path, url));
expect(response.status).toBe(200);
expect(await response.json()).toEqual(
path === "/stream"
? { ...result, missing: expect.stringContaining("Caption not found") }
: result
);
}
);
});
Loading
Loading