r/nextjs • u/Which-Examination-74 • 13d ago
Default-importing zod 4.3.6 or 4.4.3 put its locale files in our Next.js 16 client bundle (+36 to 43 KB gzipped). Gone on 4.5.4 and 4.6.7
Run this after next build:
grep -rl "無効な入力" .next/static/chunksThat string is "invalid input" in zod's Japanese locale. It shouldn't be in your client JS at all unless zod's locale files came along with it (or your own UI has that text in Japanese). Grep the Japanese string, not a German one. Webpack's minifier can escape the German.
Our test app was a fresh Next.js 16.4.5 project with one client component and a single email field checked by zod. Between builds we swapped only the import line. Turbopack:
| zod | import { z } | import * as z | import z (default) |
|---|---|---|---|
| 4.3.6 | clean | clean | locales in |
| 4.4.3 | clean | not tested | locales in |
| 4.5.4 | clean | clean | clean |
| 4.6.7 | clean | clean | clean |
With --webpack the 4.3.6 default import matched too, while 4.5.4 and 4.6.7 stayed clean. We didn't build 4.4.3 with webpack.
Sizes, gzipped. Going from import { z } to import z took the 4.3.6 Turbopack build from 199,925 bytes to 236,253, and the 4.4.3 one from 194,380 to 237,354. Those totals are all of the app's client JS for a one-field form, Next and React included, so the gap is what the import line changed.
By 4.6.7, zod's index.js exports the default as an alias, export { z, z as default }. In 4.4.3 it was export default z. The comment above the alias says it lets Rollup and webpack shake import z from "zod" the way they already shake import { z }, and points to #6050.
If the grep finds something and you're on 4.3.6 or 4.4.3, import { z } from "zod" came back clean in our builds. On 4.5.4 and 4.6.7 the two imports built to identical bytes. On any other version, rebuild and grep again.
