vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.3k stars 1.82k forks source link

turbo watch wrong hash #9104

Open vekexasia opened 1 month ago

vekexasia commented 1 month ago

Verify canary release

Link to code that reproduces this issue

turborepo/examples/with-rollup

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Linux

Which canary version will you have in your reproduction?

2.1.1

Describe the Bug

i tried the with-rollup example as it aligns with my use case.

steps:

this gives FULL TURBO ->>> Ok

now:

this gives a cache miss with a different hash and rebuilds

notes: if from here you npx turbo build again. the hash is the same as in the first steps

Expected Behavior

cache hits like in turbo build

To Reproduce

Additional context

No response

chris-olszewski commented 1 month ago

turbo watch does make use of the cache to prevent any partial artifacts from being stored in the cache. I see this isn't documented anywhere so I'll quick add it.

vekexasia commented 1 month ago

What is the proper way to have a watch rebuild + subdeps?

chris-olszewski commented 1 month ago

I don't believe I understand your question. Could you elaborate a bit?

vekexasia commented 1 month ago

I would like something like watch that honors the inputs of the task so that it triggers only when something matching the inputs changes.

MarkParnwell commented 1 month ago

I believe I am having the same issue of turbo watch not respecting task inputs.

Given a turbo.json like below

{
  "$schema": "https://turbo.build/schema.json",
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "inputs": ["$TURBO_DEFAULT$", "src/**/*.ts", "!src/**/*.spec.ts"],
      "outputs": ["dist/**"]
    }
  }
}

When I run turbo run build, change a test file and run turbo run build again, I get

 Tasks:    3 successful, 3 total
Cached:    3 cached, 3 total
  Time:    90ms >>> FULL TURBO

However, when I run turbo watch build and change a test file, the build task is re-executed each time.

choover-circle commented 1 week ago

I think this issue is right spirit but wrong to approach this as a bug but as a feature request since turbo documentation explicitly states that caching is disabled for tasks running with watch.

I would like to infact use caching with turbo watch.

My ideal behavior is that when running with turbo watch, the first run is like with turbo run where tasks that miss cache are run. After that, I would like it to watch the inputs and re-run tasks for which inputs changed.

Is this currently on a roadmap? Is caching disabled for now because its a planned feature or is there some technical limitation?