Skip to content

Commit

Permalink
debug windows
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmenPopoviciu committed Jul 1, 2024
1 parent 34b2926 commit ca9fc3a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 90 deletions.
87 changes: 0 additions & 87 deletions packages/wrangler/e2e/pages-dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,38 +134,6 @@ describe("pages dev", () => {
);
});

it("should modify worker during dev session (Functions)", async () => {
const helper = new WranglerE2ETestHelper();
const port = await getPort();
const worker = helper.runLongLived(`wrangler pages dev --port ${port} .`);

await helper.seed({
"functions/_middleware.js": dedent`
export async function onRequest() {
return new Response("Hello World!")
}`,
});

const { url } = await worker.waitForReady();

await expect(
fetch(url).then((r) => r.text())
).resolves.toMatchInlineSnapshot('"Hello World!"');

await helper.seed({
"functions/_middleware.js": dedent`
export async function onRequest() {
return new Response("Updated Worker!")
}`,
});

await worker.waitForReload();

await expect(
fetch(url).then((r) => r.text())
).resolves.toMatchInlineSnapshot('"Updated Worker!"');
});

it("should support wrangler.toml", async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed({
Expand Down Expand Up @@ -282,61 +250,6 @@ describe("pages dev", () => {
).resolves.toMatchInlineSnapshot('"Updated Worker!"');
});

it("should support modifying _routes.json during dev session", async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed({
"_worker.js": dedent`
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname === "/foo") {
return new Response("foo");
}
if (url.pathname === "/bar") {
return new Response("bar");
}
return new Response("Hello _routes.json")
}
}`,
"_routes.json": dedent`
{
"version": 1,
"include": ["/foo", "/bar"],
"exclude": []
}
`,
"index.html": dedent`
hello world
`,
});
const port = await getPort();
const worker = helper.runLongLived(`wrangler pages dev --port ${port} .`);
const { url } = await worker.waitForReady();

const foo = await fetchText(`${url}/foo`);
expect(foo).toMatchInlineSnapshot('"foo"');

const bar = await fetchText(`${url}/bar`);
expect(bar).toMatchInlineSnapshot('"bar"');

await helper.seed({
"_routes.json": dedent`
{
"version": 1,
"include": ["/foo"],
"exclude": ["/bar"]
}
`,
});
await worker.waitForReload();

const foo2 = await fetchText(`${url}/foo`);
expect(foo2).toMatchInlineSnapshot('"foo"');

const bar2 = await fetchText(`${url}/bar`);
expect(bar2).toMatchInlineSnapshot('"hello world"');
});

it("should validate _routes.json during dev session, and fallback to default value", async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed({
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/pages/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execSync, spawn } from "node:child_process";
import { existsSync, lstatSync, readFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { join, normalize, resolve } from "node:path";

Check failure on line 3 in packages/wrangler/src/pages/dev.ts

View workflow job for this annotation

GitHub Actions / Checks (macos-13)

'normalize' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 3 in packages/wrangler/src/pages/dev.ts

View workflow job for this annotation

GitHub Actions / Checks (macos-13)

'normalize' is defined but never used

Check failure on line 3 in packages/wrangler/src/pages/dev.ts

View workflow job for this annotation

GitHub Actions / Checks (ubuntu-latest)

'normalize' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 3 in packages/wrangler/src/pages/dev.ts

View workflow job for this annotation

GitHub Actions / Checks (ubuntu-latest)

'normalize' is defined but never used
import { watch } from "chokidar";
import * as esbuild from "esbuild";
import { unstable_dev } from "../api";
Expand Down Expand Up @@ -537,7 +537,7 @@ export const Handler = async (args: PagesDevArguments) => {
if (
!resolvedDep.match(/\/functions\/./) &&
!resolvedDep.match(/\.wrangler\/./) &&
resolvedDep.match(resolve(process.cwd()))
resolvedDep.match(process.cwd())
) {
currentBundleDependencies.add(resolvedDep);

Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/pages/functions/buildWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export function buildNotifierPlugin(onEnd: () => void): Plugin {
name: "wrangler notifier and monitor",
setup(pluginBuild) {
pluginBuild.onEnd((result) => {
if(result.errors.length > 0 || result.warnings.length > 0) {
if (result.errors.length > 0 || result.warnings.length > 0) {
logBuildFailure(result.errors, result.warnings);
} else {
logger.log("✨ Compiled Worker successfully");
Expand Down

0 comments on commit ca9fc3a

Please sign in to comment.