Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: wrangler pages dev doesn't recompile worker when imported dependency changes #3840

Closed
mariusGundersen opened this issue Aug 25, 2023 · 1 comment · Fixed by #6022
Assignees
Labels
bug Something that isn't working pages Relating to Pages pages-dev Relating to `pages dev` command

Comments

@mariusGundersen
Copy link

Which Cloudflare product(s) does this pertain to?

Pages

What version(s) of the tool(s) are you using?

3.6.0

What version of Node are you using?

18.13.0

What operating system are you using?

Windows

Describe the Bug

When running wrangler pages dev the worker is compiled automatically whenever a file in /functions is changed. However, if a dependency of one of those files changes it does not recompile.

For example, given

// functions/test.js
import lib from '../lib/lib.js';

export async function onRequest() {
  return new Response(`<h1>${lib()}</h1>`, {
    headers: {
      'Content-Type': 'text/html'
    }
  })
}

// lib/lib.js
export default function () {
  return 'Testing';
}

Then when running wrangler pages dev any change to functions/test.js will cause the worker to recompile and refreshing the browser page will reflect that. If however the string in lib/lib.js is changed the worker is not recompiled and refreshing the page in the browser will not reflect those changes.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@mariusGundersen mariusGundersen added the bug Something that isn't working label Aug 25, 2023
@admah admah added the pages Relating to Pages label Oct 4, 2023
@CarmenPopoviciu CarmenPopoviciu added the pages-dev Relating to `pages dev` command label Apr 24, 2024
@CarmenPopoviciu CarmenPopoviciu self-assigned this Jun 7, 2024
@CarmenPopoviciu
Copy link
Contributor

CarmenPopoviciu commented Jun 7, 2024

hi @mariusGundersen

Thank you so much for raising this issue and providing all the helpful details that you did <3.

I was able to reproduce the behaviour you described, so this is indeed an issue. In fact, we have a similar report in #4824. As I mentioned there

reloading on dependency changes actually used to work, but we seem to have introduced a regression with
#3311. I need to double check this, but preliminary testing would seem to indicate that. I
don't have enough context on those changes to know whether the regression was intentional or not, and I do not know if re-enabling
esbuild's watch mode for Pages would not introduce the same performance issues as those reported in
#3258. Something I need to look into. But I agree with the general sentiment that this
is something we should support

I will be picking up these two issues as part of https://github.com/cloudflare/workers-sdk/milestone/10 and will update here once the fix for this particular report is ready.

CarmenPopoviciu added a commit that referenced this issue Jun 25, 2024
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
CarmenPopoviciu added a commit that referenced this issue Jun 25, 2024
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
CarmenPopoviciu added a commit that referenced this issue Jun 25, 2024
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
CarmenPopoviciu added a commit that referenced this issue Jun 25, 2024
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
CarmenPopoviciu added a commit that referenced this issue Jun 28, 2024
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
CarmenPopoviciu added a commit that referenced this issue Jul 1, 2024
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
CarmenPopoviciu added a commit that referenced this issue Jul 2, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working pages Relating to Pages pages-dev Relating to `pages dev` command
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants