Skip to content

Commit 6da0496

Browse files
committed
improvement(dev): chain the cache prune into dev scripts instead of a predev hook
Review read the root `bun run dev` path as bypassing the `predev` hook and so never capping the newly-enabled cache. Turbo does fire `pre*` hooks — verified live, the run prints the prune before `next dev` — but the concern is fair in that the guarantee rested on package-manager lifecycle semantics that are invisible at the call site. Chaining it explicitly removes the question entirely: every `dev` variant now runs `bun run dev:cache:cap && …`, which holds on any invocation path, is visible in the command itself, and drops the three duplicated `predev:*` entries for one shared script. Verified on both paths — direct `bun run dev` and root `turbo run dev`, the latter printing: sim:dev: $ bun run dev:cache:cap && next dev --port 3000 sim:dev: $ bun run ../../scripts/prune-turbopack-cache.ts
1 parent 4aa07e5 commit 6da0496

5 files changed

Lines changed: 14 additions & 10 deletions

File tree

.agents/skills/dev-performance/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ If your numbers are wildly off these, suspect your method before suspecting a re
3535

3636
Never reason about one from the other, and never change either from a blog post or a default. Both are pinned explicitly so a version bump can't silently flip them.
3737

38-
The dev cache is unbounded on disk — an abandoned one in this repo reached **78 GB across 1,848 SST files**. `scripts/prune-turbopack-cache.ts` runs on `predev` and drops it past a cap (default 20 GB, `SIM_TURBOPACK_CACHE_MAX_GB` to override). Force it with `bun run dev:cache:prune`.
38+
The dev cache is unbounded on disk — an abandoned one in this repo reached **78 GB across 1,848 SST files**. `scripts/prune-turbopack-cache.ts` is chained into every `dev` script (`bun run dev:cache:cap && next dev`) and drops the cache past a cap — default 20 GB, `SIM_TURBOPACK_CACHE_MAX_GB` to override. Force it with `bun run dev:cache:prune`.
39+
40+
Chained explicitly rather than via a `predev` lifecycle hook: Turbo does fire `pre*` hooks (verified), but an explicit `&&` is visible in the command, survives any invocation path, and needs no per-variant `predev:*` duplicate.
3941

4042
## How to benchmark a dev-performance change
4143

.claude/commands/dev-performance.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ If your numbers are wildly off these, suspect your method before suspecting a re
3434

3535
Never reason about one from the other, and never change either from a blog post or a default. Both are pinned explicitly so a version bump can't silently flip them.
3636

37-
The dev cache is unbounded on disk — an abandoned one in this repo reached **78 GB across 1,848 SST files**. `scripts/prune-turbopack-cache.ts` runs on `predev` and drops it past a cap (default 20 GB, `SIM_TURBOPACK_CACHE_MAX_GB` to override). Force it with `bun run dev:cache:prune`.
37+
The dev cache is unbounded on disk — an abandoned one in this repo reached **78 GB across 1,848 SST files**. `scripts/prune-turbopack-cache.ts` is chained into every `dev` script (`bun run dev:cache:cap && next dev`) and drops the cache past a cap — default 20 GB, `SIM_TURBOPACK_CACHE_MAX_GB` to override. Force it with `bun run dev:cache:prune`.
38+
39+
Chained explicitly rather than via a `predev` lifecycle hook: Turbo does fire `pre*` hooks (verified), but an explicit `&&` is visible in the command, survives any invocation path, and needs no per-variant `predev:*` duplicate.
3840

3941
## How to benchmark a dev-performance change
4042

.cursor/commands/dev-performance.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ If your numbers are wildly off these, suspect your method before suspecting a re
3030

3131
Never reason about one from the other, and never change either from a blog post or a default. Both are pinned explicitly so a version bump can't silently flip them.
3232

33-
The dev cache is unbounded on disk — an abandoned one in this repo reached **78 GB across 1,848 SST files**. `scripts/prune-turbopack-cache.ts` runs on `predev` and drops it past a cap (default 20 GB, `SIM_TURBOPACK_CACHE_MAX_GB` to override). Force it with `bun run dev:cache:prune`.
33+
The dev cache is unbounded on disk — an abandoned one in this repo reached **78 GB across 1,848 SST files**. `scripts/prune-turbopack-cache.ts` is chained into every `dev` script (`bun run dev:cache:cap && next dev`) and drops the cache past a cap — default 20 GB, `SIM_TURBOPACK_CACHE_MAX_GB` to override. Force it with `bun run dev:cache:prune`.
34+
35+
Chained explicitly rather than via a `predev` lifecycle hook: Turbo does fire `pre*` hooks (verified), but an explicit `&&` is visible in the command, survives any invocation path, and needs no per-variant `predev:*` duplicate.
3436

3537
## How to benchmark a dev-performance change
3638

apps/sim/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ const nextConfig: NextConfig = {
240240
* is not covered by the #6078 build A/B cited below.
241241
*
242242
* The cache is unbounded on disk (an abandoned one reached 78 GB here), so
243-
* `scripts/prune-turbopack-cache.ts` runs on `predev` to cap it.
243+
* `scripts/prune-turbopack-cache.ts` is chained into every `dev` script to cap it.
244244
*/
245245
turbopackFileSystemCacheForDev: true,
246246
/**

apps/sim/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
"node": ">=22.19.0"
99
},
1010
"scripts": {
11-
"predev": "bun run ../../scripts/prune-turbopack-cache.ts",
12-
"dev": "next dev --port 3000",
13-
"predev:minimal": "bun run ../../scripts/prune-turbopack-cache.ts",
14-
"dev:minimal": "SIM_DEV_MINIMAL_REGISTRY=1 next dev --port 3000",
15-
"predev:capped": "bun run ../../scripts/prune-turbopack-cache.ts",
16-
"dev:capped": "NODE_OPTIONS='--max-old-space-size=4096' next dev --port 3000",
11+
"dev": "bun run dev:cache:cap && next dev --port 3000",
12+
"dev:minimal": "bun run dev:cache:cap && SIM_DEV_MINIMAL_REGISTRY=1 next dev --port 3000",
13+
"dev:capped": "bun run dev:cache:cap && NODE_OPTIONS='--max-old-space-size=4096' next dev --port 3000",
14+
"dev:cache:cap": "bun run ../../scripts/prune-turbopack-cache.ts",
1715
"dev:cache:prune": "bun run ../../scripts/prune-turbopack-cache.ts --force",
1816
"dev:clean": "rm -rf .next/dev/cache",
1917
"dev:webpack": "next dev --webpack",

0 commit comments

Comments
 (0)