-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wrangler): Fix
pages dev
watch mode [Functions]
The watch mode in `pages dev` for Pages Functions projects is currently partially broken, as it only watches for file system changes in the "/functions" directory, but not for changes in any of the Functions' dependencies. This means that given a Pages Function "math-is-fun.ts", defined as follows: ``` import { ADD } from "../math/add"; export async function onRequest() { return new Response(`${ADD} is fun!`); } ``` `pages dev` will reload for any changes in "math-is-fun.ts" itself, but not for any changes in "math/add.ts", which is its dependency. Similarly, `pages dev` will not reload for any changes in non-JS module imports, such as wasm/html/binary module imports. This commit fixes all these things, plus adds some extra polish to the `pages dev` watch mode experience. Fixes #3840
- Loading branch information
1 parent
7d02856
commit 238ecca
Showing
18 changed files
with
465 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: Fix `pages dev` watch mode [Functions] | ||
|
||
The watch mode in `pages dev` for Pages Functions projects is currently partially broken, as it only watches for file system changes in the | ||
"/functions" directory, but not for changes in any of the Functions' dependencies. This means that given a Pages Function `math-is-fun.ts`, defined as follows: | ||
|
||
``` | ||
import { ADD } from "../math/add"; | ||
export async function onRequest() { | ||
return new Response(`${ADD} is fun!`); | ||
} | ||
``` | ||
|
||
`pages dev` will reload for any changes in `math-is-fun.ts` itself, but not for any changes in `math/add.ts`, which is its dependency. | ||
|
||
Similarly, `pages dev` will not reload for any changes in non-JS module imports, such as wasm/html/binary module imports. | ||
|
||
This commit fixes all these things, plus adds some extra polish to the `pages dev` watch mode experience. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hi</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const x = 6; | ||
export default x; |
1 change: 1 addition & 0 deletions
1
fixtures/pages-functions-with-routes-app/animals/cats/cersei.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const Cersei = "😽😽😽😽😽😽😽😽😽😽😽😽😽😽😽😽😽"; |
1 change: 1 addition & 0 deletions
1
fixtures/pages-functions-with-routes-app/animals/cats/gracie.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const Gracie = "😽😽😽😽😽"; |
1 change: 1 addition & 0 deletions
1
fixtures/pages-functions-with-routes-app/animals/doggos/bear.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const Bear = "🐻"; |
1 change: 1 addition & 0 deletions
1
fixtures/pages-functions-with-routes-app/animals/doggos/graham.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const Graham = "😽"; |
10 changes: 10 additions & 0 deletions
10
fixtures/pages-functions-with-routes-app/functions/[foo].ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import j from "../JSMY/js.js"; | ||
// import h2 from "../my/html copy.html"; | ||
import h from "../my/html.html"; | ||
|
||
export const onRequest = () => { | ||
console.log({ j }); | ||
return new Response(h, { | ||
headers: { "Content-Type": "text/html" }, | ||
}); | ||
}; |
1 change: 1 addition & 0 deletions
1
fixtures/pages-functions-with-routes-app/functions/foo/bar/baz.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const onRequest = () => new Response("bz"); |
6 changes: 6 additions & 0 deletions
6
fixtures/pages-functions-with-routes-app/functions/greeting/math.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ADD } from "../../utils/math/add"; | ||
import { MUL } from "../../utils/math/mul"; | ||
|
||
export async function onRequest() { | ||
return new Response(`${ADD} and ${MUL} are fun!!`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hi copy</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hi!</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const ADD = "Addition!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const MUL = "multiplication"; |
Oops, something went wrong.