Skip to content

Conversation

@cdown
Copy link

@cdown cdown commented Jan 22, 2026

When following re-export chains, Turbopack would stop and include the entire module if it isn't marked sideEffects: false in package.json. This causes barrel files to pull in all their dependencies even when only one export is used.

As the existing comment notes, it is unfortunate that we have to use the whole module here, but we can fix that by allowing modules marked ModuleEvaluationIsSideEffectFree to be followed through in re-export chains. This fixes tree-shaking for packages like zod/mini where intermediate barrel files don't explicitly set sideEffects: false.

Fixes: #88643

@nextjs-bot nextjs-bot added the Turbopack Related to Turbopack with Next.js. label Jan 22, 2026
@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Jan 22, 2026

Allow CI Workflow Run

  • approve CI run for commit: 801f279

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

When following re-export chains, Turbopack would stop and include the
entire module if it isn't marked `sideEffects: false` in package.json.
This causes barrel files to pull in all their dependencies even when
only one export is used.

As the existing comment notes, it is unfortunate that we have to use the
whole module here, but we can fix that by allowing modules marked
ModuleEvaluationIsSideEffectFree to be followed through in re-export
chains. This fixes tree-shaking for packages like zod/mini where
intermediate barrel files don't explicitly set `sideEffects: false`.

Fixes: vercel#88643
@cdown cdown force-pushed the cdown/2026-01-22/tree_shake branch from 1dda742 to 801f279 Compare January 22, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Next does not tree-shake Zod correctly

2 participants