Skip to content

fix(turbo): improve cache invalidation with package.json and lockfile - #219

Merged
Gaubee merged 1 commit into
mainfrom
fix/turbo-inputs-improvements
Jan 11, 2026
Merged

Gaubee merged 1 commit into
mainfrom
fix/turbo-inputs-improvements

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 11, 2026

Copy link
Copy Markdown
Contributor

Problem

During key-ui development, we encountered issues where:

  1. Adding new dependencies to package.json didn't invalidate turbo cache
  2. Stale typecheck results were used even after dependency changes
  3. Storybook config changes didn't trigger re-runs

Solution

1. Global lockfile dependency

"globalDependencies": ["pnpm-lock.yaml"]

Any change to the lockfile now invalidates all caches globally.

2. Per-package dependency tracking

Added package.json to inputs for:

  • lint:run
  • typecheck:run
  • test:run
  • test:storybook

3. Storybook config tracking

Added .storybook/** to test:storybook inputs.

Impact

Scenario Before After
Add workspace dependency Cache hit (wrong) Cache miss (correct)
Update pnpm-lock.yaml Cache hit (wrong) Cache miss (correct)
Modify .storybook/main.ts Cache hit (wrong) Cache miss (correct)

Verification

pnpm turbo run typecheck:run --filter=@biochain/key-ui
# Cached: 0 cached, 6 total (cache properly invalidated)

Changes:
- Add globalDependencies for pnpm-lock.yaml to invalidate all caches
  when dependencies change
- Add package.json to inputs for lint, typecheck, test tasks to detect
  dependency changes per package
- Add .storybook/** to test:storybook inputs

This prevents stale cache hits when workspace dependencies change,
which caused issues during key-ui development where adding new
dependencies didn't trigger re-typecheck.
@Gaubee
Gaubee merged commit e7c9647 into main Jan 11, 2026
5 checks passed
@Gaubee
Gaubee deleted the fix/turbo-inputs-improvements branch January 11, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant