Skip to content

test: use Turborepo pack task for test isolation - #92575

Merged
timneutkens merged 7 commits into
canaryfrom
04-09-test_use_turborepo_pack_for_test_isolation
Apr 13, 2026
Merged

test: use Turborepo pack task for test isolation#92575
timneutkens merged 7 commits into
canaryfrom
04-09-test_use_turborepo_pack_for_test_isolation

Conversation

@timneutkens

@timneutkens timneutkens commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

What?

Eliminates the expensive temporary repo directory (tmpRepoDir) copy during isolated test setup by leveraging a Turborepo pack task with caching.

Why?

The previous test isolation flow copied the entire packages/ directory to a temp location, mutated every package.json to rewrite workspace dependency references, and ran pnpm pack sequentially for each package. This added ~10s+ of overhead per test suite. With Turborepo caching, repeated runs are 500ms (and can still be improved).

How?

  • Adds a pack-for-isolated-tests task to turbo.json (depends on build, outputs packed.tgz)
  • Adds a pack-for-isolated-tests script (pnpm pack --out ./packed.tgz) to every workspace package
  • Simplifies linkPackages in repo-setup.js to scan for pre-built tarballs instead of copying/rewriting/packing
  • Updates create-next-install.js to run pnpm turbo run pack (benefits from caching) and use package manager overrides (pnpm/npm/yarn) to resolve transitive workspace deps from local tarballs
  • Removes tmpRepoDir handling from base.ts and run-tests.js

Before: createNextInstall ~16s (copy + sequential pack)
After: createNextInstall ~5s (first run) / ~4s (cached)

@nextjs-bot nextjs-bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. created-by: Turbopack team PRs by the Turbopack team. tests type: next labels Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nextjs-bot

nextjs-bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

@timneutkens
timneutkens force-pushed the 04-09-test_use_turborepo_pack_for_test_isolation branch from 38d17be to 64e7468 Compare April 9, 2026 14:22

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

The next-stats-action calls linkPackages() which expects pre-built packed.tgz tarballs, but never runs turbo run pack-for-isolated-tests to create them, causing linkPackages to return an empty map and breaking the stats action.

Fix on Vercel

@nextjs-bot

Copy link
Copy Markdown
Contributor

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▁█▅▅▅
Cold (Ready in log) 443ms 443ms ▁▂▅▇▄
Cold (First Request) 1.118s 1.137s ▆▁▁▂▂
Warm (Listen) 456ms 456ms █▁██▁
Warm (Ready in log) 443ms 445ms ▂▂▇█▁
Warm (First Request) 337ms 339ms ▃▄▇█▄
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 456ms 456ms ▁▁▅▁▅
Cold (Ready in log) 441ms 444ms ▁▃▆▂▂
Cold (First Request) 1.844s 1.848s ▇▇▇▆▁
Warm (Listen) 456ms 457ms ▁▁▁▁▁
Warm (Ready in log) 442ms 439ms ▁▂▅▁▂
Warm (First Request) 1.847s 1.850s ▆▇█▆▁

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 3.851s 3.860s ▇▆██▁
Cached Build 3.870s 3.900s ▄███▄
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 13.933s 13.974s ▁▂▅▂▂
Cached Build 14.065s 14.064s ▁▂▇▃▄
node_modules Size 484 MB 484 MB █████
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
0-haxip9_1_2p.js gzip 70.8 kB 70.8 kB
0-w49p6-lp3sj.js gzip 8.53 kB 8.53 kB
0.ohhj8jknt9q.js gzip 10 kB 10 kB
0~f.lwm9m5pc_.js gzip 156 B 156 B
0~lwfcrlb4v_9.css gzip 115 B 115 B
00l6amt1fuxze.js gzip 8.44 kB 8.44 kB
02yuvqfj6_4o1.js gzip 155 B 155 B
03~yq9q893hmn.js gzip 39.4 kB 39.4 kB
032j95wq.wuxk.js gzip 7.58 kB 7.58 kB
045.7krupc1z~.js gzip 5.62 kB 5.62 kB
05k21r9yvk3k0.js gzip 152 B 152 B
07-rm6ljgtav5.js gzip 156 B 156 B
0820ujtybkzs~.js gzip 8.49 kB 8.49 kB
092m..~~duf10.js gzip 213 B 213 B
09hxeq48omqgg.js gzip 155 B 155 B
0a6maok6s0otl.js gzip 169 B 169 B
0b5f.g56~tdpf.js gzip 8.49 kB 8.49 kB
0bev5xxd6gyf9.js gzip 156 B 156 B
0e1u_qr3xr_p7.js gzip 161 B 161 B
0f7fm6o.og815.js gzip 9.16 kB 9.16 kB
0g-6qeq6mw02g.js gzip 10.3 kB 10.3 kB
0lr2ff0i38hn-.js gzip 48.6 kB 48.6 kB
0m9_h-~x-f31e.js gzip 8.45 kB 8.45 kB
0ole95xu1-.31.js gzip 155 B 155 B
0ryec.7l9qzrz.js gzip 451 B 451 B
0sqgql~5t841k.js gzip 155 B 155 B
0t1~3g1a1khs..js gzip 13.2 kB 13.2 kB
0tq3mxrv2thsv.js gzip 9.74 kB 9.74 kB
0tv84r9horc2_.js gzip 8.52 kB 8.52 kB
0w1ednpt9-ub7.js gzip 12.9 kB 12.9 kB
11aabjmdkdq_w.js gzip 12.9 kB 12.9 kB
11j~pbyu49g6n.js gzip 65.6 kB 65.6 kB
11rh5a8jgsk-5.js gzip 1.46 kB 1.46 kB
12.._of9lytm6.js gzip 2.28 kB 2.28 kB
12im.h-a2ekav.js gzip 8.55 kB 8.55 kB
12xu7d61hawg~.js gzip 154 B 154 B
13et30cvuy4km.js gzip 159 B 159 B
16egnbhk3o2e7.js gzip 8.51 kB 8.51 kB
170x9h9ad-5_5.js gzip 155 B 155 B
17cq4nzdqf_q1.js gzip 13.7 kB 13.7 kB
17wsq5~pckqpt.js gzip 225 B 225 B
turbopack-01..n804.js gzip 4.16 kB 4.16 kB
turbopack-01..szg2.js gzip 4.16 kB 4.16 kB
turbopack-02..ueeh.js gzip 4.16 kB 4.16 kB
turbopack-02.._7kv.js gzip 4.14 kB 4.14 kB
turbopack-03..2wj8.js gzip 4.16 kB 4.16 kB
turbopack-07..oeh7.js gzip 4.16 kB 4.16 kB
turbopack-09..0-d2.js gzip 4.16 kB 4.16 kB
turbopack-0b..6dje.js gzip 4.16 kB 4.16 kB
turbopack-0i..yk_b.js gzip 4.16 kB 4.16 kB
turbopack-0i..9f-x.js gzip 4.16 kB 4.16 kB
turbopack-0q.._pir.js gzip 4.16 kB 4.16 kB
turbopack-0w..kgh-.js gzip 4.16 kB 4.16 kB
turbopack-0x..fs6u.js gzip 4.16 kB 4.16 kB
turbopack-10..d7id.js gzip 4.18 kB 4.18 kB
Total 463 kB 463 kB

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 707 B 707 B
Total 707 B 707 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 432 B 432 B
Total 432 B 432 B

📦 Webpack

Client

Main Bundles
Canary PR Change
4127-HASH.js gzip 5.54 kB 5.54 kB
6.HASH.js gzip 166 B 166 B
7083-HASH.js gzip 4.59 kB 4.59 kB
7306-HASH.js gzip 61.3 kB 61.3 kB
c33d797c-HASH.js gzip 62.7 kB 62.7 kB
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 254 B 254 B
main-HASH.js gzip 39.1 kB 39.1 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
Total 235 kB 235 kB
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 182 B 182 B
css-HASH.js gzip 334 B 334 B
dynamic-HASH.js gzip 1.81 kB 1.81 kB
edge-ssr-HASH.js gzip 255 B 255 B
head-HASH.js gzip 350 B 350 B
hooks-HASH.js gzip 381 B 381 B
image-HASH.js gzip 580 B 580 B
index-HASH.js gzip 258 B 258 B
link-HASH.js gzip 2.52 kB 2.52 kB
routerDirect..HASH.js gzip 321 B 321 B
script-HASH.js gzip 384 B 384 B
withRouter-HASH.js gzip 313 B 313 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.98 kB 7.98 kB

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 125 kB 125 kB
page.js gzip 269 kB 269 kB
Total 394 kB 394 kB ✅ -110 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 622 B 622 B
middleware-r..fest.js gzip 151 B 151 B
middleware.js gzip 43.8 kB 43.8 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 45.4 kB 45.4 kB
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 720 B 720 B
Total 720 B 720 B
Build Cache
Canary PR Change
0.pack gzip 4.27 MB 4.27 MB
index.pack gzip 107 kB 107 kB
index.pack.old gzip 105 kB 105 kB
Total 4.48 MB 4.48 MB ✅ -2.57 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 333 kB 333 kB
app-page-exp..prod.js gzip 181 kB 181 kB
app-page-tur...dev.js gzip 333 kB 333 kB
app-page-tur..prod.js gzip 181 kB 181 kB
app-page-tur...dev.js gzip 329 kB 329 kB
app-page-tur..prod.js gzip 179 kB 179 kB
app-page.run...dev.js gzip 330 kB 330 kB
app-page.run..prod.js gzip 179 kB 179 kB
app-route-ex...dev.js gzip 76.1 kB 76.1 kB
app-route-ex..prod.js gzip 51.8 kB 51.8 kB
app-route-tu...dev.js gzip 76.1 kB 76.1 kB
app-route-tu..prod.js gzip 51.8 kB 51.8 kB
app-route-tu...dev.js gzip 75.7 kB 75.7 kB
app-route-tu..prod.js gzip 51.6 kB 51.6 kB
app-route.ru...dev.js gzip 75.7 kB 75.7 kB
app-route.ru..prod.js gzip 51.5 kB 51.5 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.3 kB 43.3 kB
pages-api-tu..prod.js gzip 33 kB 33 kB
pages-api.ru...dev.js gzip 43.3 kB 43.3 kB
pages-api.ru..prod.js gzip 33 kB 33 kB
pages-turbo....dev.js gzip 52.7 kB 52.7 kB
pages-turbo...prod.js gzip 38.6 kB 38.6 kB
pages.runtim...dev.js gzip 52.7 kB 52.7 kB
pages.runtim..prod.js gzip 38.6 kB 38.6 kB
server.runti..prod.js gzip 62.4 kB 62.4 kB
Total 2.95 MB 2.95 MB
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/0eddb2b3b83768fb05473499de6a2a3a51a0bacd/next

@timneutkens
timneutkens marked this pull request as ready for review April 9, 2026 18:09
@timneutkens
timneutkens requested review from ztanner April 9, 2026 18:09
Comment thread .github/actions/next-stats-action/src/prepare/repo-setup.js
Comment thread packages/next-rspack/package.json
Comment thread .github/actions/next-stats-action/src/prepare/repo-setup.js
@timneutkens
timneutkens force-pushed the 04-09-test_use_turborepo_pack_for_test_isolation branch from 0eddb2b to ca7c0c9 Compare April 9, 2026 20:04
Eliminates the expensive temporary repo directory copy during test setup
by leveraging a Turborepo `pack` task. Instead of copying the entire
`packages/` directory, mutating `package.json` files, and running
`pnpm pack` sequentially, the new flow:

- Adds a `pack` task to `turbo.json` that depends on `build` and
  outputs `packed.tgz` in each package directory
- Adds a `pack` script (`pnpm pack --out ./packed.tgz`) to every
  workspace package
- Simplifies `linkPackages` to scan for pre-built tarballs instead of
  copying/rewriting/packing
- Uses package manager `overrides` (pnpm/npm/yarn) to resolve
  transitive workspace dependencies from local tarballs
- Removes `tmpRepoDir` handling from `base.ts` and `run-tests.js`

This reduces isolated test setup from ~16s to ~5s on cache hit.
@timneutkens
timneutkens force-pushed the 04-09-test_use_turborepo_pack_for_test_isolation branch from 4b8b004 to f3b323c Compare April 10, 2026 11:44
@timneutkens
timneutkens merged commit 263dac3 into canary Apr 13, 2026
340 of 344 checks passed
@timneutkens
timneutkens deleted the 04-09-test_use_turborepo_pack_for_test_isolation branch April 13, 2026 15:38
eps1lon added a commit that referenced this pull request Apr 29, 2026
In #92575 we started using
Turborepo to build a fresh copy of Next.js before each test. This can
become quite noisy IMO since Turborepo replays logs by default. Now we
hide logs for cache hits.

If you want to debug logs from cached builds, you should use `pnpm
build` directly.


```terminal
@next/polyfill-nomodule#build > cache hit, suppressing logs 951e3e04258a486d 
 @next/playwright#build > cache hit, suppressing logs a37fc1279a93411b 
 @next/routing#build > cache hit, suppressing logs e29bf8207712d9ea 
 @next/env#build > cache hit, suppressing logs 6f68cdf7c8f202f6 
 @next/bundle-analyzer-ui#build > cache hit, suppressing logs 5dbf9112c4f7029e 
 @next/polyfill-module#build > cache hit, suppressing logs 601b6f5afa47853d 
 @vercel/devlow-bench#build > cache hit, suppressing logs dfd1c037ef4e8100 
 @next/codemod#build > cache hit, suppressing logs a5eac293134b4263 
 @next/react-refresh-utils#build > cache hit, suppressing logs 51d64c1f7e8e5cfb 
 @next/eslint-plugin-next#build > cache hit, suppressing logs 74ec27fec9910c71 
 create-next-app#build > cache hit, suppressing logs 0c4c9d38e0e0913e 
 @next/font#build > cache hit, suppressing logs d1d057c5ffe70285 
 @next/bundle-analyzer#pack-for-isolated-tests > cache hit, suppressing logs 867b1e9082440087 
 @next/env#pack-for-isolated-tests > cache hit, suppressing logs 50d7a018277cafb8 
 next-rspack#pack-for-isolated-tests > cache hit, suppressing logs 1046e9cfa3ba6879 
 @next/mdx#pack-for-isolated-tests > cache hit, suppressing logs 6da45b672b5b081a 
 eslint-config-next#build > cache hit, suppressing logs fcf529c5b1428c5d 
 @next/font#pack-for-isolated-tests > cache hit, suppressing logs 9675f7ed199b9841 
 next#build > cache hit, suppressing logs 8c62df3806949bad 
 @vercel/turbopack-next#build > cache hit, suppressing logs 94890b06e4b937bf 
 @next/third-parties#build > cache hit, suppressing logs f1da8c56f9222a0c 
 next#pack-for-isolated-tests > cache hit, suppressing logs f11a5a11e2584c14 
 @next/third-parties#pack-for-isolated-tests > cache hit, suppressing logs 988b5be9471a943e
```
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

create-next-app Related to our CLI tool for quickly starting a new Next.js application. created-by: Turbopack team PRs by the Turbopack team. locked tests type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants