I've ran into significant build performance issues since upgrading next.js from v13.2.4 to v13.3.0 or higher. The build duration of a project I'm working on became easily 2-7x slower after the upgrade. Building on vercel usually takes about 10 minutes, but after the upgrade it was 25-30 minutes, unacceptable in my workflow so I had to revert to v13.2.4.
After a lot of digging I was able to narrow it down to the v13.2.5-canary.26 release.
Luckily, it is easy to reproduce the issue with this simple next.js repo.
This repo contains a simple next.js project with a pages-directory containing
200 pages (/number/[number].tsx
) which fake a 1 second delay before rendering
the page. Not sure if this is relevant, but it helps to make the issue more
visible.
- Clone this repo
- Run
npm install
- this will install next@v13.2.4 - Run
rm -rf .next
to remove the build cache (if any) - Run
npm run build
- measure the build duration - Run
npm install next@v13.2.5-canary.26
- Run
rm -rf .next
to remove the build cache - Run
npm run build
- measure the build duration
The second build will/should be significantly slower. See below for my results in finding the offending release.
0m30s
fornext@v13.2.4
30 seconds is the expected duration0m31s
fornext@v13.2.5-canary.14
0m30s
fornext@v13.2.5-canary.22
0m31s
fornext@v13.2.5-canary.24
0m31s
fornext@v13.2.5-canary.25
3m30s
fornext@v13.2.5-canary.26
⚠️ this is where the build duration starts to degrade (next@v13.2.5-canary.26 release notes)3m34s
fornext@v13.2.5-canary.28
3m33s
fornext@v13.2.5-canary.29
3m23s
fornext@v13.3.4
maybe it got fixed somewhere in the v13.3.x range, but 13.3.4 doesnt show any improvement1m01s
fornext@v13.4.5
good improvement in next's latest release(s), but still 2x slower than v13.2.41m02s
fornext@13.4.6-canary.0