chore: import upstream snapshot with attribution
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:30:11 +08:00
commit 70bf21e064
5213 changed files with 731895 additions and 0 deletions
@@ -0,0 +1,5 @@
export default {
fetch() {
return new Response("hello from _worker.js");
},
};
@@ -0,0 +1,5 @@
export default {
fetch() {
return new Response("hello from custom/script/path/index.js");
},
};
@@ -0,0 +1,19 @@
{
"name": "@fixture/pages-dev-proxy",
"private": true,
"sideEffects": false,
"scripts": {
"dev": "wrangler pages dev public",
"test:ci": "vitest run",
"test:watch": "vitest",
"type:tests": "tsc -p ./tests/tsconfig.json"
},
"devDependencies": {
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "catalog:default",
"typescript": "catalog:default",
"undici": "catalog:default",
"vitest": "catalog:default",
"wrangler": "workspace:*"
}
}
@@ -0,0 +1,75 @@
import { ChildProcess, fork } from "node:child_process";
import path from "node:path";
import { setTimeout } from "node:timers/promises";
import { fetch, Response } from "undici";
import { describe, it, onTestFinished } from "vitest";
import { runWranglerPagesDev } from "../../shared/src/run-wrangler-long-lived";
describe("Pages dev with proxy and a script file", () => {
it("should handle requests using a script from the default _worker.js path", async ({
expect,
}) => {
const process = await startWranglerPagesDevProxy();
const combinedResponse = await waitUntilReady(
`http://127.0.0.1:${process.port}/`
);
const respText = await combinedResponse.text();
expect(respText).toMatchInlineSnapshot('"hello from _worker.js"');
expect(
process
.getOutput()
.includes(
"Specifying a `-- <command>` or `--proxy` is deprecated and will be removed in a future version of Wrangler."
)
).toBeTruthy();
expect(
process
.getOutput()
.includes(
"On Node.js 17+, wrangler will default to fetching only the IPv6 address. Please ensure that the process listening on the port specified via `--proxy` is configured for IPv6."
)
).toBeTruthy();
});
it("should handle requests using a script from a custom script path", async ({
expect,
}) => {
const process = await startWranglerPagesDevProxy([
"--script-path=custom/script/path/index.js",
]);
const combinedResponse = await waitUntilReady(
`http://127.0.0.1:${process.port}/`
);
const respText = await combinedResponse.text();
expect(respText).toMatchInlineSnapshot(
'"hello from custom/script/path/index.js"'
);
});
});
async function startWranglerPagesDevProxy(extraArgs: string[] = []) {
const process = await runWranglerPagesDev(
path.resolve(__dirname, ".."),
undefined,
["--port=0", "--proxy=9999", ...extraArgs]
);
onTestFinished(process.stop);
return process;
}
async function waitUntilReady(url: string): Promise<Response> {
let response: Response | undefined = undefined;
while (response === undefined) {
await setTimeout(500);
try {
response = await fetch(url);
} catch (e) {}
}
return response as Response;
}
@@ -0,0 +1,7 @@
{
"extends": "@cloudflare/workers-tsconfig/tsconfig.json",
"compilerOptions": {
"types": ["node"]
},
"include": ["**/*.ts"]
}
@@ -0,0 +1,12 @@
{
"include": ["index.d.ts"],
"compilerOptions": {
"target": "ES2020",
"module": "preserve",
"lib": ["ES2020"],
"types": ["@cloudflare/workers-types"],
"moduleResolution": "node",
"noEmit": true,
"skipLibCheck": true
}
}
@@ -0,0 +1,9 @@
import { defineProject, mergeConfig } from "vitest/config";
import configShared from "../../vitest.shared";
export default mergeConfig(
configShared,
defineProject({
test: {},
})
);